Splash 完成后更改 ViewController

Posted

技术标签:

【中文标题】Splash 完成后更改 ViewController【英文标题】:Changing ViewController when the Splash has finished 【发布时间】:2014-01-13 16:28:59 【问题描述】:

我想在 Splash 结束后更改 viewController;我有这个:

//Implementación de los métodos:
- (void) cargaImagenes
    //Asginación de ficheros de imagen a las variables
    splash1 =[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Ejemplo1.jpg"]];
    splash2 =[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Ejemplo2.jpg"]];

    //Ocultamos las imágenes
    splash1.alpha = 0.0;
    splash2.alpha = 0.0;
    //Las ponemos como subvistas a la vista principal del ViewController
    [self.view addSubview:splash1];
    [self.view addSubview:splash2];

    // Presentación mediante animación del primer splash.
    //Dos bloques de código: 1.- Tipo de animación del splash1. 2.- Se ejecuta un timer con un segundo de duración, que cuando termina, se ejecuta el metodo showSecondSplash.
    [UIView animateWithDuration:0.5 animations:^
        splash1.alpha = 1.0;
     completion:^(BOOL finished)
        [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(showSecondSplash:) userInfo:nil repeats: NO];
    ];



-(void) showSecondSplash:(NSTimer *) timer
    //Ocultamos el primer splash, mostramos el segundo splash y programamos un timer para que se oculte el segundo y comience la aplicacion.
    [UIView animateWithDuration:0.5 animations:^
        splash1.alpha = 0.0;
        splash2.alpha=1.0;
     completion:^(BOOL finished)
        [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(finishSplash:) userInfo:nil repeats:NO];
    ];

-(void) finishSplash:(NSTimer *) timer 
    //Ocultamos el segundo splash
    //Eliminamos ambos splash de la vista
    [UIView animateWithDuration:0.5 animations:^
        splash2.alpha = 0.0;
     completion:^(BOOL finished)
        [splash1 removeFromSuperview];
        [splash2 removeFromSuperview];
    ];


我希望当它完成后,我的故事板中出现 NavigationViewController,这个使用 Splash 的 View Controller 是初始视图,然后是带有 tableViewController 的 NavigationViewController。 从该视图到 NavigationViewController 具有模态样式的 segue。 如何?谢谢。

【问题讨论】:

【参考方案1】:

也许我不太清楚你的问题……

这是你要找的吗?

-(void) finishSplash:(NSTimer *) timer 
    //Ocultamos el segundo splash
    //Eliminamos ambos splash de la vista
    [UIView animateWithDuration:0.5 animations:^
        splash2.alpha = 0.0;
     completion:^(BOOL finished)
        [splash1 removeFromSuperview];
        [splash2 removeFromSuperview];
        [self performSegueWithIdentifier:@"YourSegueIdentifier" sender:self];
    ];


【讨论】:

以上是关于Splash 完成后更改 ViewController的主要内容,如果未能解决你的问题,请参考以下文章

Mac环境下安装运行splash

(Android)react-native-splash-screen实践-解决react-native打包好后启动白屏的问题

Splash

配置scrapy-splash+python爬取医院信息(利用了scrapy-splash)

JavaScript 动态渲染页面爬取 —— 基于 Splash

JavaScript 动态渲染页面爬取 —— 基于 Splash