当UITableView编辑状态发生变化时,更改UIBarButtonItem

时间:2014-11-20 21:34:25

标签: ios uitableview swift uibarbuttonitem

我知道这是可能的,我想我错过了一些明显的东西,但对于我的生活,我无法理解。我正在尝试根据UIBarButtonItem是否处于编辑模式,将UITableView从一个项目更改为另一个项目。到目前为止,我已经完成了

@IBOutlet var btnAddFriend: UIBarButtonItem!
@IBOutlet var btnFriendRequests: UIBarButtonItem!
@IBOutlet var tblFriendsList: UITableView!
@IBOutlet var ntbFriendList: UINavigationItem!


override func tableView(tableView: UITableView, willBeginEditingRowAtIndexPath indexPath: NSIndexPath) {
    ntbFriendList.rightBarButtonItem = btnAddFriend
}

override func tableView(tableView: UITableView, didEndEditingRowAtIndexPath indexPath: NSIndexPath) {
    ntbFriendList.rightBarButtonItem = btnFriendRequests
}

但切换编辑模式时都不会触发任何功能。

任何帮助?

0 个答案:

没有答案