Ios Xcode应用程序赢得';有时不能查看负载视图
我的项目运行时没有故事板,因此我在AppDelegate中加载我的视图:Ios Xcode应用程序赢得';有时不能查看负载视图,ios,objective-c,xcode,xib,Ios,Objective C,Xcode,Xib,我的项目运行时没有故事板,因此我在AppDelegate中加载我的视图: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.windo
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window = window;
self.window.rootViewController = [[SYLoginController alloc] init];
[self.window makeKeyAndVisible];
return YES;
}
它过去在iPhone6Sim9.3上工作,但现在,在所有模拟器上它只显示一个黑屏。但在我的iphone6设备上,它可以工作。而在另一款iphone6上,它也显示了一个黑屏。这两部iPhone几乎是同时购买的16gb iphone6
在SYLoginController
sviewDiDLoad
中,我正在记录其中一个按钮的文本。它只在我的设备上打印文本,在所有模拟器和其他iPhone上打印(null),因此我假设xib没有正确加载
SYLoginController
是一个UIViewController
,相关的xib持有一个UIView,其文件所有者设置为SYLoginController
。我真的不明白为什么它只在这个特定的设备上工作。我还尝试了[[SYTabBarController alloc]initWithNibName:@“SYLoginController”bundle:nil]
,这也不起作用…您是否尝试将其环绕在导航控制器周围
SYLoginController *syVC = [[SYLoginController alloc]initWithNibName:@"SYLoginController" bundle:nil];
UINavigationController *nav = [[UINavigationController alloc] syVC];
self.window.rootViewController = nav;
还要再次检查XIB文件中的自定义类是否设置为SYLoginController。视图已连接到文件所有者。我尝试过,现在它是一个带有黑屏的导航控制器(您可以看到导航栏)…是的,您可以隐藏导航栏。但奇怪的是。。。检查XIB文件。打印出视图框架尺寸。给SyLoginController另一个backgroundcolor。我可以使用self.window.backgroundcolor设置视图的backgroundcolor,但似乎没有加载xib。奇怪的是,在我的iphone上,它能正常工作。在运行该项目之前,您是否尝试过清理(Cmd-K)或卸载真实设备中的应用程序?它不应该在真正的设备上也工作。我尝试了清理项目,我尝试了清理derivedData,ich也卸载了应用程序好几次。一部iPhone可以工作,另一部不能,模拟器也不能。