Xcode 4.2 iOS 5:来自 UITableView 的多个 segues [英] Xcode 4.2 iOS 5 : Multiple segues from a UITableView

查看:20
本文介绍了Xcode 4.2 iOS 5:来自 UITableView 的多个 segues的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在开始使用适用于 iOS5 的 4.2 上的 Xcode,并且有一些更改,我现在遇到了一个我无法找到解决方法的问题.

I'm starting now with Xcode on 4.2 for iOS5 and there are a few changes and I'm now crossing a problem that I can't figure out a way to solve it.

我正在做一个 UITablwView 示例,它以编程方式填充 2 个部分,第一个部分只有 1 行,第二个部分有 3 行.

I'm doing an example with a UITablwView that is populated programmatically with 2 Sections, 1st section with only 1 Row, and 2nd Section with 3 Rows.

我的目标是从表中选择一行,并根据该行将用户重定向到不同的视图.

My aim is to select a row from the table, and based on that row, the user will be redirected to different Views.

例如:选择第 0 行第 0 行,应用推送到视图 1 - 名称设置//选择第 1 行第 0 行,应用推送查看 3 - 地址设置

For example: selecting section 0 row 0, app pushes to view 1 - name setting // selecting section 1 row 0, app pushes to view 3 - address setting

老式的方式,这很简单,只需要使用 initWithNibName 初始化一个 UIViewController 然后推送视图.

The old fashion way, this is quite simple, just needed to init a UIViewController with initWithNibName and then push the view.

现在随着storyBoard一切都变了,或者至少我认为它变了,因为我看不到如何获得相同的结果,因为我无法将tableView中的多个segue设置为不同的UIViewControllers......并且做老式方式我看不到我可以从故事板上的视图中获取 NIB 名称以初始化 UIViewController 来推送.

Now with the storyBoard everything changes, or at least I think it changes because I can't see how to get the same result since I can't set multiple segue's from the tableView to different UIViewControllers...and to do the old fashion way I can't see where I can get the NIB names from the views on the storyBoard to init an UIViewController to push.

有谁知道如何得到这个结果??

Does any one knows how to get to this result??

推荐答案

从源视图控制器的情节提要中定义两个通用"segue(例如,标识为segue1"和segue2"),一个到每个目标视图控制器.这些 segue 不会与任何操作相关联.

Define two "generic" segues (identified as "segue1" and "segue2", for example) in the storyboard from your source view controller, one to each destination view controller. These segues won't be associated with any action.

然后,有条件地在 UITableViewDelegate 中执行转场:

Then, conditionally perform the segues in your UITableViewDelegate:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Conditionally perform segues, here is an example:
    if (indexPath.row == 0)
    {
        [self performSegueWithIdentifier:@"segue1" sender:self];
    }
    else
    {
        [self performSegueWithIdentifier:@"segue2" sender:self];
    }
}

这篇关于Xcode 4.2 iOS 5:来自 UITableView 的多个 segues的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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