iphone - PushViewController 导致黑屏

标签 iphone objective-c xcode

SettingsViewController *viewController = [[SettingsViewController alloc] init];
    [[self navigationController] pushViewController:viewController animated:YES];

在 NavigationController 中使用此代码时,显示的场景只是黑屏。在 Storyboard 中显示内容,但不显示在手机上。

最佳答案

试试这个:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle: nil];
SettingsViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"setting"];
[self.navigationController pushViewController:viewController animated:YES];

设置settingviewcontroller的标识符为“setting”

关于iphone - PushViewController 导致黑屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14929039/

相关文章:

ios - AVPlayer 和 AVPlayerItem 状态什么时候改变?

iphone - MKAnnotation协议(protocol)的 "coordinate"属性

iphone - 为什么使用 NSFetchedResultsController?

ios - XCode 11.3、装有 iOS 13.2.2 的模拟器 iPhone X 和装有 watchOS 4.2 的 Apple Watch 42mm 时崩溃

xcode 7 无法将类型 '[NSHTTPCookie]' 的值分配给类型 '[NSHTTPCookie]' 的值

ios - dyld:未加载库:@executable_path/../Frameworks/

ios - UIDevice iOS 的非公共(public) API 用法和 uniqueidentifier 方法

objective-c - 从 subview IOS 更改父 View 中的数据

objective-c - 有没有使用 ALAssetsLibrary 快速检查用户访问权限的方法?

ios - 绘图层 : inContext on UILabel