Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/100.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS:减少应用程序进入前台时UIAlertView显示的延迟_Ios_Ios7_Xcode5_Uialertview_Uialertsheet - Fatal编程技术网

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

iOS:减少应用程序进入前台时UIAlertView显示的延迟,ios,ios7,xcode5,uialertview,uialertsheet,Ios,Ios7,Xcode5,Uialertview,Uialertsheet,我已经创建了一个受密码保护的应用程序。该应用程序允许在后台运行。 当它返回前台时,我会显示一个警报,提示用户输入密码,方法是覆盖appdelegate中的applicationWillEnterForeground:方法,如下所示- - (void)applicationWillEnterForeground:(UIApplication *)application { if (/*password is enabled*/) { alertview = [[UIA

我已经创建了一个受密码保护的应用程序。该应用程序允许在后台运行。 当它返回前台时,我会显示一个警报,提示用户输入密码,方法是覆盖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];
    }

}
但是,警报需要一点时间才能显示。在此期间,视图仍然很脆弱

有没有办法让uialertview立即显示?

dispatch\u async(dispatch\u get\u main\u queue()^{
dispatch_async(dispatch_get_main_queue(), ^{
    <# Write UI related code to be executed on main queue #>
});
});
dispatch\u async(dispatch\u get\u main\u queue()^{
});

您可以尝试在主线程上对此发出警报。Ashutosh,我是ios编程的新手。你能给我提供一个链接或示例,说明当应用程序返回前台时,如何在主线程上显示警报吗?你可以尝试在主线程上显示警报。Ashutosh,我对ios编程相当陌生。你能给我提供一个链接或示例,说明当应用程序返回前台时,如何在主线程上显示警报吗?谢谢你的及时回复!如果我理解正确,这个块将进入“applicationWillEnterForeground:”appdelegate方法(在我的例子中是这样的),对吗?工作起来很有魅力!谢谢!谢谢你的及时回复!如果我理解正确,这个块将进入“applicationWillEnterForeground:”appdelegate方法(在我的例子中是这样的),对吗?工作起来很有魅力!谢谢!