单点触控中带有繁重代码的启动画面 [英] Splash screen with heavy codes in monotouch

查看:20
本文介绍了单点触控中带有繁重代码的启动画面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们现在在单点触控和 iPhone/ipad 应用程序中,当我们想在应用程序午餐前显示启动画面时,我们应该在 info.plist 文件中设置启动图像,它会在应用程序启动之前显示该图像.

We now that in monotouch and for iPhone / ipad application when we want to have splash screen before app lunch we should to set launch image in info.plist file and it will show this image before application launches.

但是当我们想要在后台运行一些繁重的代码并且在这些操作没有完成之前不会消失的启动画面时,实现启动画面的最佳方法是什么?一些代码,例如从互联网下载应用程序配置和保存启动画面中经常使用的主题.

But what is the best way to implement a splash screen when we want to have a splash that runs some heavy codes in background and not disappear until these operations had not completed? Some codes like downloading application config from internet and saving theme that often used in splash screen.

推荐答案

顺便说一句,还有一个解决方案:创建主UIViewController,在里面立即设置为Window.RootViewControllerAppDelegate 的 FinishedLaunching 方法.然后通过以下代码创建和显示模态splashViewController:

BTW, there is another solution: create main UIViewController, set it as Window.RootViewController immediately in AppDelegate's FinishedLaunching method. Then create and show modally splashViewController by this code:

    ...
    MainViewController.PresentModalViewController(splashViewController, true);
    ...

可以通过调用代码隐藏模态UIViewController:

Hiding modal UIViewController is possible via calling code:

    DismissModalViewControllerAnimated(true);

请注意,由于 iOS 6 PresentModalViewController 成为不推荐使用的方法.因此,对于许多 iOS 版本的兼容性,您可以编写特殊方法来显示模态 UIViewController.

Note that since iOS 6 PresentModalViewController becomes deprecated method. So, for many iOS versions compatibility you could code special method for showing modal UIViewController.

    public void ShowModalViewController (UIViewController vc, bool animated)
    {
        if (UIDevice.CurrentDevice.CheckSystemVersion(6, 0)) {
            MainViewController.PresentViewController(vc, animated, null);
        } else {
            MainViewController.PresentModalViewController(vc, animated);
        }
    }

这篇关于单点触控中带有繁重代码的启动画面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆