从TableView中选择的对象加载不同的视图控制器

时间:2012-02-02 11:12:54

标签: objective-c ipad ios5

我需要一些帮助来解决这个问题。我创建了一个UITabBarController,其中有两个标签。在其中一个中,我使用UIPopoverController弹出UITableViewUIPopoverController。我使用表视图数据源加载tableView和两个对象,我可以在UIPopoverController出现时看到它们。

您可以在此处查看截图:

Screenshot

现在我想要实现的是,当我点击反馈然后我需要被引导/带到feedbackViewController和其他对象下载相同,它应该带我到{{1} }。

我知道我需要使用表格视图方法:

downloadViewController

但我不知道如何做到这一点。因此,我将不胜感激任何关于如何处理这个问题的一般信息。

1 个答案:

答案 0 :(得分:1)

听起来很简单。您需要做的就是确定按下了哪个按钮,在本例中为0表示反馈,1表示下载。然后根据当前适当的视图控制器。 您可能需要链接到父级,这将最终显示新视图。否则,您将在弹出控制器内显示视图。

创建/显示UIPopoverController创建对父级

的引用时的某处
UIViewController *mainparent = _mainparent; //where _mainparent is the reference passed through.

然后在-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;中加入以下内容。

if (indexPath.row == 0)
    [mainparent presentModalViewController:feedbackViewController animated:YES];
else
    [mainparent presentModalViewController:downloadViewController animated:YES];

这将以模态方式呈现所需的视图控制器。