iPhone故事板编辑表格视图 [英] iPhone Storyboard Editing a table view

查看:257
本文介绍了iPhone故事板编辑表格视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试在Xcode中学习新的Storyboard功能,并且在尝试将UITableView设置为编辑模式时遇到了问题。

I've been trying to learn the new Storyboard feature in Xcode and I've run into a problem with trying to set a UITableView to edit mode.

所以我的故事板看起来像这样:

So far my storyboard looks like this:

NavigationController - > UIViewController(带有tableview属性的子类)

NavigationController -> UIViewController (subclass with tableview property)

我添加了一个导航项和条按钮项到视图控制器场景,所以我看到一个编辑按钮。它没有自动执行任何操作,因此我尝试将其选择器链接到tableview委托的setEditing方法。这确实使它进入了编辑模式。但是,编辑按钮没有更改为完成按钮,因此无法退出编辑模式。

I added a Navigation Item and a Bar Button item to the view controller scene, so I do see an edit button. It didn't do anything automagically, so I tried linking it's selector to the setEditing method of the tableview delegate. This did put it into editing mode. However, the edit button did not change to a "Done" button and so there is no way to get out of editing mode.

我是否必须创建另一个导航项完成按钮?如何连接它以便它在正确的时间出现并正常工作?

Do I have to create another Navigation item for the Done button? How do I connect it so that it appears at the right time and works correctly?

推荐答案

我刚开始使用故事板,所以我还想使用Storyboard添加我的编辑按钮。花时间学习如何使用新工具但发现需要一卷胶带来修补孔是很烦人的。

I just started using Storyboards, so I also wanted to use the Storyboard to add my Edit button. It is annoying to have taken the time to learn how to use a new tool but find you need a roll of duct tape to patch up the holes.

你可以让它工作,但需要添加一个自定义按钮。在属性检查器中,确保标识符为自定义,标题为编辑。

You can get it to work, but need to add a Custom button. In the Attributes inspector make sure the Identifier is Custom and the title is Edit.

然后在你的.m中添加这样的东西

Then add something like this in your .m

- (IBAction)setEditMode:(UIBarButtonItem *)sender {
    if (self.editing) {
        sender.title = @"Edit";
        [super setEditing:NO animated:YES];
    } else {
        sender.title = @"Done";
        [super setEditing:YES animated:YES];
    } 
}

让自定义编辑按钮调用setEditMode方法。

Have your Custom Edit button call the setEditMode method.

希望他们将来能够在Storyboard编辑器中修复Edit按钮的实现。

Can only hope they will fix the implementation of the Edit button in the Storyboard editor in the future.

这篇关于iPhone故事板编辑表格视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆