UITableview edit/done button(UITableview 编辑/完成按钮)
问题描述
我在顶部有一个表格视图和导航栏.
I have a tableview and navigation bar on the top.
我的导航栏左侧有一个编辑按钮,其中包含以下代码行.
I have a Edit button on the left of my navigation bar with the following line of code.
self.navigationItem.leftBarButtonItem = self.editButtonItem;
当我点击编辑按钮时,它变为完成按钮.到目前为止一切都很好.
When i click on the edit button, it changes to done button. All is fine so far.
如果我想在点击完成按钮时做一个小操作,我应该在哪里添加代码?
Where do i add code, if i want to do a small operation when the Done button is clicked.?
推荐答案
一旦你用 self.editButtonItem.action = @selector(editClicked:);
你应该做的是在你自己的控制器类中重写 UIViewController 的 setEditing 方法:
What you should do is override UIViewController's setEditing method in your own controller class:
- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
[super setEditing:editing animated:animated];
if(editing == YES)
{
// Your code for entering edit mode goes here
} else {
// Your code for exiting edit mode goes here
}
}
您还需要在情节提要中将 UIBarButtonItem 设置为编辑",或者如果您更喜欢在代码中执行此操作,请使用以下代码:
You also need to set your UIBarButtonItem to "Edit" in storyboard or if you prefer doing it in code use the following:
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
editButtonItem 是系统已经为您设置的辅助属性.
editButtonItem is a helper property already set by the system for your comfort.
这篇关于UITableview 编辑/完成按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:UITableview 编辑/完成按钮


- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01