Note that there are some explanatory texts on larger screens.

plurals
  1. POUITableView inside UIView not working as expected with UITextField
    primarykey
    data
    text
    <p>Ok guys so here's the problem. I'm loading a UITableView inside a UIView and it's not displaying the two textfields:</p> <p>.h:</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface LoginViewController : UIViewController &lt;UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate&gt; { UITableView *loginTableView; UITextField *username; UITextField *password; } @property UITableView *loginTableView; @property UITextField *username; @property UITextField *password; @end </code></pre> <p>.m:</p> <pre><code>#import &lt;QuartzCore/QuartzCore.h&gt; #import "LoginViewController.h" @interface LoginViewController () @end @implementation LoginViewController @synthesize loginTableView, username, password; - (void)viewDidLoad { [super viewDidLoad]; // Make rounded corners view [self.view.layer setCornerRadius:4.0]; [self.view.layer setMasksToBounds:YES]; self.view.layer.opaque = NO; self.view.backgroundColor = [UIColor whiteColor]; // Add login table view to main view loginTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)]; loginTableView.delegate = self; loginTableView.dataSource = self; [self.view addSubview:loginTableView]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return 2; } - (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [table dequeueReusableCellWithIdentifier:@"Cell"]; if( cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"]; } if (indexPath.row == 0) { username = [[UITextField alloc] initWithFrame:CGRectMake(5, 0, 280, 21)]; username.placeholder = @"Username"; username.autocorrectionType = UITextAutocorrectionTypeNo; [username setClearButtonMode:UITextFieldViewModeWhileEditing]; cell.accessoryView = username; } if (indexPath.row == 1) { password = [[UITextField alloc] initWithFrame:CGRectMake(5, 0, 280, 21)]; password.placeholder = @"Password"; password.secureTextEntry = YES; password.autocorrectionType = UITextAutocorrectionTypeNo; [password setClearButtonMode:UITextFieldViewModeWhileEditing]; cell.accessoryView = password; } username.delegate = self; password.delegate = self; [loginTableView addSubview:username]; [loginTableView addSubview:password]; cell.selectionStyle = UITableViewCellSelectionStyleNone; return cell; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 1; } @end </code></pre> <p>Anyone could please tell me what I'm doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload