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;
}
精彩评论