I am creating a uitableview that has two sections, section == 0 has 5 rows, and section == 1 has 1 row.
I have also declared several functions in an objective-c class that I would like to hook into each of the five rows. However I am not sure how to implement this.
I am thinking it is something like
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
cell.selectionStyle = UITableViewCellSelectionStyleNone;
//---------- In here put a bunch of IF statments, declaring each cell? and linking it to
//---------- the function I have declared in the objective-c class
return cell;
}
Usually the cells are setup in
tableView:cellForRowAtIndexPath:. Determining the function that’s called when a cell is tapped is usually done intableView:didSelectRowAtIndexPath.When setting up the cell in
tableView:cellForRowAtIndexPath:you can specify the section and row usingindexPathlike this:Do something similar in
tableView:didSelectRowAtIndexPathwhen determining which function is called when the user taps each cell. The relevant documentation from Apple can be found here.