我試圖在啓動應用程序時顯示密碼/ pincode(模式視圖控制器)。你可以看到在AppDelegate.h的代碼:啓動應用程序時顯示密碼/ Pincode - Storyboard
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"passcode_in"]) {
//display passcode screen
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"PasscodeViewController"];
[vc setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentModalViewController:vc animated:NO];
} else {
NSLog(@"No Passcode Screen");
}
return YES;
}
的問題是,AppDelegate中不支持顯示模態的視圖控制器(presentModalViewController)。我不打算使用.xib文件,只有我的應用程序的Storyboard。有人知道它有什麼問題嗎?任何建議表示讚賞。
議決
我跟着給我以前貼的問題之一指令https://stackoverflow.com/a/10303870/1344459我只添加一些代碼到兩種方法applicationDidEnterBackground和applicationWillTerminate在AppDelegate.m爲PinCodeViewController(解決問題模式)啓動應用程序後。現在它運作得如此順利。
爲了澄清,通過自定義segue呈現此登錄屏幕的ViewController應該是您的初始視圖控制器。 – geraldWilliam 2012-04-24 23:35:44
這對我的其他UIViewControllers來說是一個很好的選擇,但對於Login和PinCode屏幕來說卻不是。在啓動應用程序時,我只在AppDelegate.m中添加了一些代碼到兩個方法** applicationDidEnterBackground **和** applicationWillTerminate **中,用於PinCodeViewController(模態)。現在它運作得如此順利。感謝您的幫助。 – hightech 2012-04-26 14:53:51