在UITableViewCell上点击执行条件segue [英] Conditional segue performed on tap on UITableViewCell

查看:189
本文介绍了在UITableViewCell上点击执行条件segue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Xcode 4.2为iOS 5开发一些项目。我有一个UITableViewController,并希望在用户点击表格单元格时执行segue,但目标视图控制器依赖于对该单元格执行的操作。例如,当用户点击单元格时我想加载SomeViewController,但是当用户在编辑模式下点击同一单元格时,我想加载AnotherViewController。不幸的是,没有办法在Xcode 4.2 storyboard builder中的同一个单元格上配置多个segue,或者我只是没有得到它。也许有一种方法可以在代码编辑器中手动创建segue。通常我想要实现的是为用户提供一种方法,使用一个视图控制器输入由单元格表示的项目,并使用另一个视图控制器编辑由同一单元格表示的项目。在表编辑模式下切换到第二个视图控制器(编辑器)只是我的第一个,但也许有更好的方法。任何帮助将不胜感激。

I'm working on some project for iOS 5 using Xcode 4.2. I have one UITableViewController and want to perform a segue when user tap on table cell, but destination view controller depends on action performed on that cell. For example, when user tap on cell I would like to load SomeViewController, but when user tap on the same cell in editing mode I would like to load AnotherViewController. Unfortunately, there is no way to configure multiple segues on same cell in Xcode 4.2 storyboard builder, or I just don't get it. Perhaps there is a way to create segue by hand, in code editor. Generally what I want to achieve is to provide user a way to "enter" the item represented by cell using one view controller and "edit" the item represented by the same cell using another view controller. Switching to the second view controller (editor) when in table-edit-mode only was my first though, but maybe there is a better way. Any help will be appreciated.

推荐答案

在查看Storyboard时,从源视图控制器控制拖动到目标视图控制器。这将创建一个segue,您可以直接从源视图控制器触发。确保你给Segue一个名字。这个名称将传递给源视图控制器的performSegue:withIdentifier:方法。

While looking Storyboard, control-drag from your source View Controller to your Destination view controller. This will create a segue that you can trigger programmatically right from your source View Controller. Ensure that you give you Segue a name. This name is what you will pass into the source View Controller's performSegue:withIdentifier: method.

这篇关于在UITableViewCell上点击执行条件segue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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