【问题标题】:pushViewController doesn't work after an Xcode 9 updateXcode 9 更新后 pushViewController 不起作用
【发布时间】:2017-10-23 08:44:59
【问题描述】:

我使用的是 xib 而不是 storyBord。 问题是当我想更改应用程序上的窗口时。 我可以加载下一个窗口,但我不能用 pushViewController 显示它,我通知你在更新 Xcode 之前它已经工作了。

感谢您的回复
按钮点击方法:

`MesFic *vueMesFic=[[MesFic alloc] initWithNibName:@"MesFic" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:vueMesFic animated:YES];
[vueMesFic release];
vueMesFic=nil;`

我的 appDelegate.m

MyStyleSheet * myStyleSheetInstance = [[MyStyleSheet alloc] init];
[TTStyleSheet setGlobalStyleSheet:myStyleSheetInstance];
[myStyleSheetInstance release];
// Override point for customization after application launch.

//[self.window addSubview:[navigationController view]];

[self.window makeKeyAndVisible];
[window setRootViewController:navigationController];
return YES;

【问题讨论】:

  • 我确定,你在这里遇到了错误[vueMesFic release];
  • 加入主队列。
  • 确保应用程序窗口有navigationController。
  • self.navigationController 为零吗?你在vueMesFic=nil; 之后做吗?
  • No self.navigationController 不是 nil

标签: ios objective-c xib xcode9


【解决方案1】:

如果您使用的是navigationController,请确保您已将navigationController 设置为您的根控制器。

MyStyleSheet * myStyleSheetInstance = [[MyStyleSheet alloc] init];

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:myStyleSheetInstance];
[window setRootViewController:navigationController];

在这种情况下,您可以使用 self.navigation 进行导航

[self.navigationController pushViewController:vueMesFic animated:YES];

如果你不愿意使用 UINavigation,

 MyStyleSheet * myStyleSheetInstance = [[MyStyleSheet alloc] init];
[window setRootViewController:myStyleSheetInstance];

然后使用

[self presentViewController:viewController animated:YES completion:nil];

也许对你有帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-04
    • 2021-01-02
    • 2018-06-07
    • 1970-01-01
    • 2015-10-14
    相关资源
    最近更新 更多