How to setup cells in a static table divided in sections programitcally
I'm basically making a settings view on my app and I'm using a static
table for it. So I divided the table into 3 sections each with one cell.
Not programmatically I can easily label each cell and it works but
programmatically I'm not able to initialize each cell. I can only
initialize the first cell that gets repeated across the 3 sections. I
would like a way to initialize a cell for each section but I can't find a
method or a way to do that. My tableview also has reuseIdentifiers but it
doesn't seem like the UITableViewController recognizes it.
This is what I have done so far.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
#warning Potentially incomplete method implementation.
// Return the number of sections.
return 3;
}
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
#warning Incomplete method implementation.
// Return the number of rows in the section.
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"EditProfile";
//UITableViewCell *cell = nil; //[tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
// More initializations if needed.
}
//Observations *currentList = [self.teacherNames
objectAtIndex:indexPath.row];
cell.textLabel.text = @"Hey";
//return cell;
return cell;
}
But what I want is the cell in the first section to be labeled: Edit
Profile, the second one: Invite and the third:Logout
No comments:
Post a Comment