One Quickie


Finding the row from a tableview cell button (UITableView->General)
You can add buttons to a UITableViewCell. The fun part is figuring out what row that button lives on. Assuming that the button is added right to the cell, you can look at the button's superview to get the cell, and then ask the tableview for the cell's section and row.
- (IBAction) elaborateType: (id) sender {
    if (![sender isKindOfClass: [UIButton class]]) return;  // be paranoid

    UITableViewCell *cell = (UITableViewCell *)[sender superview];
    if (![cell isKindOfClass: [UITableViewCell class]]) return;  // be paranoid

    NSIndexPath *indexPath = [self.kindPickerTableView indexPathForCell: cell];

    // do something with indexPath.row and/or indexPath.section.

} // elaborateType



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com