[英]How to start an iOS app with a modal view controller already presented without the user being able to see the presenting view?
I've tried many combinations of doing this from the app delegate, the presenting view controller's viewDidLoad
, with and without delay, with and without animation. 我已经尝试了很多组合来做这个从app委托,呈现视图控制器的viewDidLoad
,有和没有延迟,有和没有动画。
But either the user can see the presenting view controller for a moment, or the modal doesn't get presented. 但是用户可以暂时看到呈现视图控制器,或者模式没有呈现。
How can this be achieved? 怎么能实现这一目标?
Tried code below with storyboard, app starts with modal view controller: 使用storyboard尝试下面的代码,应用程序以模态视图控制器启动:
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self.window makeKeyAndVisible];
[self.window.rootViewController performSegueWithIdentifier:@"modalSegue" sender:self];
return YES;
}
Segue configuration from start view controller to modal view controller: 从开始视图控制器到模态视图控制器的配置:
What if your inititalViewController had a picture of your launch image over it. 如果你的inititalViewController上面有你的启动图像的图片怎么办?
@property (nonatomic, weak) IBOutlet UIImageView *launchImage;
Set the launch image before the view appears. 在视图出现之前设置启动图像。
- (void)viewWillAppear
{
self.launchImage.image = [self launchImage];
}
Here's a link to get the launch image . 这是获取启动图像的链接 。
Then when you present the modal view controller, remove the launch image. 然后,当您呈现模态视图控制器时,删除启动图像。
[self presentViewController:vc animated:NO completion:^{
[self.launchImage removeFromSuperview];
}];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.