3 回答

TA貢獻1828條經驗 獲得超13個贊
我回答了一個類似的問題,開發人員希望在開始時顯示登錄屏幕。我為他整理了一些示例代碼,可以在此處下載。解決此問題的關鍵是,如果要顯示此新的視圖控制器,則在正確的時間調用事物,您將在示例中看到必須使用類似的東西
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
[vc setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentModalViewController:vc animated:YES];
}
我也有一個關于segue和情節提要如何工作的解釋,您可以在這里看到

TA貢獻1820條經驗 獲得超9個贊
在ViewDidLoad中加載會導致“底層”閃爍。我通過以編程方式加載情節提要來解決此問題。因此,在“目標/主故事板”下-將此留空。然后添加以下內容:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Load Main App Screen
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
HomeScreenVC *homeScreenVC = [storyboard instantiateInitialViewController];
self.window.rootViewController = homeScreenVC;
[self.window makeKeyAndVisible];
// Load Login/Signup View Controller
UIViewController *mainLoginVC = [storyboard instantiateViewControllerWithIdentifier:@"MainLoginVC"];
[mainLoginVC setModalPresentationStyle:UIModalPresentationFullScreen];
[homeScreenVC presentModalViewController:mainLoginVC animated:NO];
return YES;
}

TA貢獻1906條經驗 獲得超3個贊
問題是您要在完全添加第一個視圖之前將第二個視圖添加到層次結構中。嘗試將代碼放入:
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
// Present your modal from here
}
[super viewDidAppear]調用之后,您將具有完全加載的視圖以進行修改。
- 3 回答
- 0 關注
- 816 瀏覽
添加回答
舉報