Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting when a cell's detail-disclosure button has been clicked (when using a custom cell XIB)

if (cell == nil)       // 1
{                      // 2
   [[NSBundle mainBundle] loadNibNamed:@"TVCell" owner:self options:nil];  // 3
   cell = tvCell;      // 4
   self.tvCell = nil;  // 5
}                      // 6

There's some code from an Apple example of using your own "custom cell XIB" to create cells in a UITableView.

It appears to work... but I think I would do better to actually understand what is being done there.

  • Why isn't the following assigning the value to something?

    cell = [[NSBundle mainBundle] loadNibNamed:@"TVCell" owner:self options:nil];
    

    (In fact, cell and tvCell aren't being used at all.)

  • Why is line #4 assigning using tvCell when nothing has been put it in at all, yet?

  • Why is line #5 nulling out the tvCell that I need?

  • Why is this line using assign, not retain?

    @property (nonatomic, assign) IBOutlet UITableViewCell *tvCell;
    

About the only thing I can't get working correctly is when I put a disclosure-button on my custom cell XIB. Is there a way for me to detect when the user has clicked on it? (Hopefully, without using 100s of TAGs.)

like image 561
Gloria Avatar asked Apr 22 '10 04:04

Gloria


1 Answers

I haven't played with XIBs for cells, but I don't see why you couldn't still use tableView:accessoryButtonTappedForRowWithIndexPath:.

like image 66
shosti Avatar answered Sep 24 '22 22:09

shosti