开发者

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

开发者 https://www.devze.com 2022-12-27 13:55 出处:网络
if (cell == nil)// 1 {// 2 [[NSBundle mainBundle] loadNibNamed:@\"TVCell\" owner:self options:nil];// 3
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 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.)


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

0

精彩评论

暂无评论...
验证码 换一张
取 消