0

我正在使用此功能,但它不起作用。我正在使用 StoryBoard 和 xcode 4.3。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Navigation logic may go here. Create and push another view controller.
    [tableView deselectRowAtIndexPath:indexPath animated:YES];

     pushnavViewController *detailViewController = [[pushnavViewController alloc] initWithNibName:@"pushnavViewController" bundle:nil];

    detailViewController.pushh.text = [listt objectAtIndex:indexPath.row];
     // Pass the selected object to the new view controller.
     [self.navigationController pushViewController:detailViewController animated:YES];

}
4

3 回答 3

1

这是答案:

当您使用故事板时,您必须使用

pushnavViewController *detailViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"pushnavViewController"];

不是

     pushnavViewController *detailViewController = [[pushnavViewController alloc] initWithNibName:@"pushnavViewController" bundle:nil];

另外,不要忘记从 storyborad 设置标识符。

于 2012-06-29T05:20:33.010 回答
0

我想我会从评论中删除这个并尝试解决方案。抱歉,这不是一个直接的解决方案,而是更多的建议......

也许最好的做法是(如果您使用 Xcode 4.x)创建一个新项目,选择“主从应用程序”模板。查看 AppDelegate 类,看看 MasterViewController 是如何添加为 UINavigationController 的根视图控制器的。看看这是如何工作的,并尝试将其应用于您的情况。

此外,请查看 UINavigationController 的类参考。

于 2012-06-28T22:25:59.633 回答
0

1- 创建故事板标识符:pushnavViewController 点击 ViewController,选择标签身份检查器 ==> 故事板 ID:pushnavViewController

2- 使用 Storyboard Identifier 启动 UIViewController

 UIStoryboard *mainStoryboard = self.storyboard;
    UIViewController *mainViewController = [mainStoryboard instantiateViewControllerWithIdentifier:@"pushnavViewController"];

3- 推送到另一个 ViewController [self.navigationController pushViewController:mainViewController animated:YES];

这是代码:

-(void) openABCPage
{
    UIStoryboard *mainStoryboard = self.storyboard;
    UIViewController *mainViewController = [mainStoryboard instantiateViewControllerWithIdentifier:@"pushnavViewController"];
    [self.navigationController pushViewController:mainViewController animated:YES];

}
于 2013-08-27T01:46:57.100 回答