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.tvCe开发者_如何学编程ll = 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
andtvCell
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.)
I haven't played with XIBs for cells, but I don't see why you couldn't still use tableView:accessoryButtonTappedForRowWithIndexPath:
.
精彩评论