-1

当我尝试推送到视图控制器时,我的应用程序崩溃了。只有当我们尝试导航到另一个页面(push 和 presentModal)时才会发生这种情况。我还检查了IBOutlets视图控制器中应该推送的连接和其他连接。但是找不到线索。这是我进行推送的代码:

PhoneBookView *phoneBook = [[PhoneBookView alloc] initWithNibName:@"PhoneBook" bundle:[NSBundle mainBundle]];

[self.navigationController presentModalViewController:phoneBook animated:YES];
4

7 回答 7

1

为您提供信息'presentModalViewController:animated:' is deprecated: first deprecated in iOS 6.0

尝试这个:

PhoneBookView *phoneBook = [[PhoneBookView alloc] initWithNibName:@"PhoneBookView" bundle:[NSBundle mainBundle]];
[self.navigationController presentViewController:phoneBook animated:YES completion:nil];
于 2013-09-12T09:26:00.050 回答
0
PhoneBookView *phoneBook = [[PhoneBookView alloc] initWithNibName:@"PhoneBook" bundle:[NSBundle mainBundle]];

[self.navigationController presentModalViewController:phoneBook animated:YES];

使用代码呈现视图控制器

PhoneBookView *phoneBook = [[PhoneBookView alloc] initWithNibName:@"PhoneBook" bundle:[NSBundle mainBundle]];

[self presentModalViewController:phoneBook animated:YES];

并推送视图控制器

PhoneBookView *phoneBook = [[PhoneBookView alloc] initWithNibName:@"PhoneBook" bundle:[NSBundle mainBundle]];

[self.navigationController pushViewController:phoneBook animated:YES];
于 2013-09-12T09:24:56.643 回答
0

[self.navigationController presentModalViewController:phoneBook animated:YES];此方法已弃用

相反,您可以使用

[self presentViewController:<#(UIViewController *)#> animated:<#(BOOL)#> completion:<#^(void)completion#>]

self presentViewController:phoneBook animated:YES completion:nil]
于 2013-09-12T09:42:01.173 回答
0

你可以试试这个,不需要指定捆绑,

PhoneBookView *phoneBook=[[PhoneBookView alloc] initWithNibName:@"PhoneBook" bundle:nil];

[self.navigationController pushViewController:phoneBook animated:YES];
于 2013-09-12T09:49:46.007 回答
0
 PhoneBookView *phoneBook = [[PhoneBookView alloc] initWithNibName:@"PhoneBook" bundle:[NSBundle mainBundle]];
 UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:phoneBook];

[self.navigationController presentModalViewController:nav animated:YES];

如果要在呈现视图后进行推送操作,则需要添加 UINavigation 控制器作为该呈现视图的根视图控制器。

快乐的编码...

于 2013-09-12T09:39:25.210 回答
0

重置iOS模拟器,退出xcode并重新启动它,看看它是否对你有帮助,这似乎不是你的代码错误,而是xcode或模拟器之一。

于 2013-09-12T10:02:17.773 回答
-2

尝试以下:

PhoneBookView *phoneBook = [[PhoneBookView alloc] initWithNibName:@"PhoneBookView" bundle:[NSBundle mainBundle]];

于 2013-09-12T09:31:56.700 回答