我正在使用故事板,如下圖所示,我正面臨錯誤我的代碼已成功執行,但它們沒有頁面顯示或模擬器中的操作僅在啓動圖像後顯示黑屏。以編程方式顯示故事板視圖
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
我不明白我是如何設置故事板和什麼是導航控制器的初始控制器?請告訴我如何知道根視圖控制器?解釋它並請解決我的問題。 –