0

我已经设置了一个表格视图。在主视图中,我使用了一条警告消息:如果用户单击确定按钮,则表视图将打开。

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 0) {
        //do nothing
    }
    else if (buttonIndex == 1) {
        myTableViewController *nextViewController = [[myTableViewController alloc] initWithNibName:nil bundle:nil];
        [self presentViewController:nextViewController animated:YES completion:nil];
    }
}

表格视图确实会显示,但缺少某些部分。顶部有一个导航栏,底部有一个工具栏,都不见了。仅显示单元格。

当我从其他方法过渡到这个表格视图时,它可以正常显示,所以我不知道出了什么问题。

任何人都可以帮忙吗?谢谢!

4

2 回答 2

1

如果要呈现视图,则需要创建UINavigationController

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 0) {
        //do nothing
    }
    else if (buttonIndex == 1) {
        myTableViewController *nextViewController = [[myTableViewController alloc] initWithNibName:nil bundle:nil];

        /* BEGIN NEW CODE */
        /* Here, you will init the navController with your table controller as the root, this is important. */
        UINavigationController *controller = [[UINavigationController alloc] initWithRootViewController:nextViewController];
        [controller setModalPresentationStyle:UIModalPresentationFormSheet];
        [controller setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
        /* END NEW CODE */

        /* You will now present "controller" instead of the table controller */
        [self presentViewController:controller animated:YES completion:nil];
    }
}

我还要注意,您需要myTableViewController.

于 2012-04-29T05:29:20.963 回答
0

您正在调用 presentViewController ,它不会将其推送到导航堆栈,而是以模态方式将其显示在当前视图的顶部。你想打电话:

[self.navigationController pushViewController:nextViewController animated:YES];
于 2012-04-29T05:25:30.827 回答