当选择UITableView中的行时,将显示UINavigation栏中的“完成”按钮


我想

在选择UITableView中的任何行时显示完成按钮UINavigationBar,我希望此按钮performSegueWithIdentifier执行操作。关于如何实现它的任何想法?

将以下内容添加到表中View:didSelectRowAtIndexPath: 方法:

//add done button to navigation bar
UIBarButtonItem *doneBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(userPressedDone)];
self.navigationItem.rightBarButtonItem = doneBarButtonItem;

然后在视图控制器的某个地方有一个这样的方法:

-(void)userPressedDone {
    //perform segue
    [self performSegueWithIdentifier:@"mySegue" sender:nil];
}
我想在您的

-didSelectRowAtIndexPath:方法中,您会在视图控制器navigationItem的右侧或左侧栏按钮项中添加一个UIBarButtonItem

最新更新