iOS:当应用程序进入前台时,减少UIAlertView显示的延迟

Zax*_*ter 0 uialertview uialertsheet ios ios7 xcode5

我创建了一个受密码保护的应用.该应用程序允许在后台运行.当它返回到前台时,我会通过覆盖appdelegate中的applicationWillEnterForeground:方法来显示提醒用户输入密码的提示,如下所示 -

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    if (/*password is enabled*/)    {
        alertview = [[UIAlertView alloc] initWithTitle:@"LOGIN"
                                               message:@"Enter app password"
                                              delegate:self
                                     cancelButtonTitle:nil
                                     otherButtonTitles:nil];
        alertview.alertViewStyle = UIAlertViewStyleSecureTextInput;
        pwdTF = [alertview textFieldAtIndex:0];
        [pwdTF setDelegate:self];
        [alertview show];
    }

}
Run Code Online (Sandbox Code Playgroud)

但是,警报需要一些时间才能显示.在此期间,视图仍然容易受到攻击.

有没有办法立即制作uialertview节目?

Ash*_*osh 5

dispatch_async(dispatch_get_main_queue(), ^{
    <# Write UI related code to be executed on main queue #>
});
Run Code Online (Sandbox Code Playgroud)