开发者

iPhone, how do I disable / enable a nav button based on table view row selection?

I want to only have my navigation bar select button enabled when a row in my table view is sele开发者_运维问答cted.

How ?


Use the enabled property on UIBarItem (superclass of UIBarButtonItem) to enable/disable it in your table view's delegate's tableView:didSelectRowAtIndexPath: and tableView:didDeselectRowAtIndexPath: methods.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  self.navigationItem.rightBarButtonItem.enabled = YES;
}

- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
  self.navigationItem.rightBarButtonItem.enabled = NO;
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜