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 关注
- 779 浏览
添加回答
举报