通过Modal View呈现详细视图控制器

时间:2012-06-15 10:22:49

标签: iphone ios modal-dialog cell didselectrowatindexpath

我正在开发我的第一个应用程序,一切都很顺利,直到这个(唯一剩下要做的事情)。情况如下:

我在主视图控制器中有一个表视图。所以,当有人选择一行时,我想显示另一个视图控制器(详细视图控制器),但我需要通过模态视图而不是按推送来呈现它,因为我没有使用表视图控制器,所以在主视图中只有一个简单的表视图。 。有可能吗?如果是这样,我该如何实现" didSelectRowAtIndexPath"?

感谢您的帮助,我现在试图解决这个问题3天了,哈哈,

1 个答案:

答案 0 :(得分:1)

在MainViewController中,设置tableView.delegate = self 现在实现didSelectRowAtIndexPath,在其中您将执行以下操作

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    //Use indexPath.row or indexPath.section to get your data
    YourViewController *controller = [[YourViewController alloc] init];
    controller.someData = [someArray objectAtInde:indexPath.row];
    [self presentModalViewController:controller animated:YES];
}
相关问题