简体   繁体   English

如何在没有用户能够看到呈现视图的情况下使用模态视图控制器启动iOS应用程序?

[英]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.

相关问题 为什么模式视图(由详细视图控制器呈现)呈现视图控制器是拆分视图控制器? - Why modal view's (presented by detail view controller) presenting view controller is split view controller? 如何在呈现的View Controller和呈现的View Controller之间建立关系? - How to setup a relationship between the presenting View Controller and the presented View Controller? 如何暂时隐藏同时呈现视图控制器的呈现视图控制器 - How to temporarily hide a presented View controller that is also presenting a view controller 为什么在applicationDidFinishLaunchingWithOptions中未显示模态视图控制器? - Why is the modal view controller not being presented in applicationDidFinishLaunchingWithOptions? 在iOS中呈现模态视图控制器不起作用 - Presenting Modal View Controller in iOS not working 出现2/3次后,不再显示模态视图控制器 - Modal view controller not presented anymore after being presented 2/3 times iOS /自动版式:取消已演示的控制器后,更改为演示视图 - IOS/Autolayout: Change to Presenting View After Presented Controller Dismissed 展示没有情节提要的模态视图控制器 - presenting a modal view controller without storyboard UIViewController-将没有Flash的呈现视图控制器切换为呈现一个? - UIViewController - switch presented view controller without flash to presenting one? 呈现模态视图控制器时呈现视图控制器响应触摸事件 - Presenting view controller response touch events when modal view controller is presented
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM