First import the table view delegates into your .h file and make sure you follow this format,
@interface CustomtableViewController : UITableViewController<UITableViewDelegate, UITableViewDataSource> { UITextField * username; UIButton * submit; } @implementation CustomtableViewController - (void)viewDidLoad { UIView *newView = [[UIView alloc]initWithFrame:CGRectMake(10, 70, 300, 45)]; submit = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [submit setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
Here I created only two text fields for username and password. You can use the else if clause to insert any number of text fields into each of the consecutive lines according to your needs.
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { return [NSString stringWithFormat:@"User Login"]; } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { return 50; } - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section { return @""; }
So, my code here is only used to create a login page with two text fields (Username and Password) and a Login button. You can change my code according to your needs. Hooray!
source share