我正在使用故事板,如下图所示,我正面临错误我的代码已成功执行,但它们没有页面显示或模拟器中的操作仅在启动图像后显示黑屏。以编程方式显示故事板视图
ClsMainPageAppDelegate.h
#import <UIKit/UIKit.h>
@interface ClsMainPageAppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
ClsMainPageAppDelegate.m
#import "ClsMainPageAppDelegate.h"
#import "ClsMainPageViewController.h"
#import "ClsTermsandConditionViewController.h"
@implementation ClsMainPageAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
NSUserDefaults *fetchDefaults = [NSUserDefaults standardUserDefaults];
int message = [fetchDefaults integerForKey:@"checkvalue"];
NSLog(@"Message Hello : %i",message);
if(message == 1)
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
ClsMainPageViewController *mvc = [storyboard instantiateViewControllerWithIdentifier:@"BeIinformedPage"];
[(UINavigationController*)self.window.rootViewController pushViewController:mvc animated:NO];
NSLog(@"Launched Home Page");
}
else
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
ClsTermsandConditionViewController *mvc = [storyboard instantiateViewControllerWithIdentifier:@"termsandConditionControl"];
[(UINavigationController*)self.window.rootViewController pushViewController:mvc animated:NO];
NSLog(@"Launched Terms and Conditions Page");
}
return YES;
}
错误
这个错误时,我没有选择的切入点在storybroad是初始我面对查看Controll呃。
2013-07-17 19:38:12.749 BeInformed[1011:c07] Failed to instantiate the default view
controller for UIMainStoryboardFile 'MainStoryboard' - perhaps the designated entry
point is not set?
2013-07-17 19:38:16.127 BeInformed[1011:c07] Message Hello : 0
2013-07-17 19:38:18.333 BeInformed[1011:c07] Launched Terms and Conditions Page
错误
此错误当我选择storybroad切入点,我面对的是初始视图控制器(termsandConditionControl)
2013-07-17 19:53:19.839 BeInformed[1057:c07] Message Hello : 0
2013-07-17 19:53:26.175 BeInformed[1057:c07] - [ClsTermsandConditionViewController
pushViewController:animated:]: unrecognized selector sent to instance 0x71b2f50
2013-07-17 19:53:26.176 BeInformed[1057:c07] *** Terminating app due to uncaught
exception 'NSInvalidArgumentException', reason: '-[ClsTermsandConditionViewController
pushViewController:animated:]: unrecognized selector sent to instance 0x71b2f50'
你的故事板是如何设置的?导航控制器是初始控制器吗?它的根视图控制器是什么? – rdelmar
您可以使用一些错误检查来查看故事板和视图是否成功返回。此外,'(UINavigationController *)self.window.rootViewController'看起来可疑,应该测试。 – Jenn
我不明白我是如何设置故事板和什么是导航控制器的初始控制器?请告诉我如何知道根视图控制器?解释它并请解决我的问题。 –