I have a list of text items which populate a list. The code for it looks like this:
// CREATING EACH CELL IN THE LIST
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"business";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if(!cell){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:17];
cell.textLabel.numberOfLines = 0;
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
}
cell.textLabel.text = [cellTitleArray objectAtIndex:indexPath.row];
// CLOSE THE SPINNER
[spinner stopAnimating];
// return the cell for the table view
return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
UIFont *cellFont = [UIFont fontWithName:@"Helvetica" size:17];
CGSize constraintSize = CGSizeMake(self.itemList.frame.size.width, MAXFLOAT);
CGSize labelSize = [[cellTitleArray objectAtIndex:indexPath.row] sizeWithFont:cellFont constrainedToSize:constraintSize lineBreakMode:UILineBreakModeWordWrap];
return labelSize.height + 30;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
What I want to do is to give the person a choice to edit each item. One way it makes sense to do that is by making it a 2-column list and on the right side column to make a character like “>” so they can tap it and it will give them an option to edit the item.
How can that be done in this case?
Thanks!
To capture a row click:
If you watch to capture a click on just a button, or similar:
If you wish to use the
accessoryType, you would place this code in yourcellForRowAtIndexPathmethod.Then you action something on the click like so
If you
indexPath.rowisn’t enough to differentiate between your clicks (I can’t see why it wouldn’t be!) then you can always usesetTagon your disclosure button.