Zaxter
Zaxter

Reputation: 3035

iOS: Decrease delay in UIAlertView show when app enters foreground

I have created a password protected app. The app is allowed to run in background. When it returns to foreground, I display an alert to prompt the user for password, by overriding the applicationWillEnterForeground: method in appdelegate like so-

- (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];
    }

}

However, the alert takes a little time to appear. During this time, the view remains vulnerable.

Is there a way to make uialertview show instantly?

Upvotes: 0

Views: 746

Answers (1)

Ashutosh
Ashutosh

Reputation: 2225

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

Upvotes: 5

Related Questions