导航控制器显示黑屏 [英] Navigation Controller shows black screen

查看:25
本文介绍了导航控制器显示黑屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在学习 iOS 开发时遇到了一些导航控制器的问题.

I was learning iOS dev and met some problems with Navigation Controller.

我创建了一个 SingleView 应用程序,然后使用嵌入导航控制器"来获取导航控件.

I created a SingleView application then use "Embed In Navigation Controller" to get a navigation control.

我遇到的问题是,app成功搭建后,只有导航栏可见,其他UI组件都是纯黑色的.我已经在真实设备上尝试过,清理/重建,删除应用程序&重新构建,都得到了相同的结果.

The problem I met is, after the app successfully build up, only the navigation bar is visible, other UI components are nothing but pure black. I've tried on real device, clean/rebuild, delete the app & re-build, all got the same result.

截图如下:

故事板截图:

点击导航控制器时:

我已尝试更新约束和框架,因此没有黄色三角形警告.

I have tried update the constraints and frames, so there's no amber triangle warnings.

是初始视图控制器"已经打勾.

"Is Initial View Controller" is already ticked.

代码:

AppDelegate.m

AppDelegate.m

#import "AppDelegate.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end

AppDelegate.h

AppDelegate.h

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end

=== 更新 ====

=== UPDATE ====

使用 UINavigationController 而不是 UIViewController

有关详细信息,请参阅已接受的答案.

Please see the accepted answer for details.

推荐答案

我看了你的代码.在 ViewController.h 你有:

I looked at your code. In ViewController.h you have:

@interface ViewController : UINavigationController <UITableViewDelegate, UITableViewDataSource>

只需将其更改为

@interface ViewController : UIViewController

它会出现!

导航控制器正在尝试显示另一个空导航控制器!:)

The navigation controller is trying to show another empty navigation controller! :)

这篇关于导航控制器显示黑屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆