Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > UIAlertView delayed presentation

UIAlertView delayed presentation
Thread Tools
Professional Poster
Join Date: Jan 2000
Location: Columbus, OH
Status: Offline
Reply With Quote
May 24, 2014, 10:58 AM
 
I've a most annoying bug.
This UIAlertView doesn't display immediately but after the code that follows the [alertView show] line.

Code:
myFantasticViewController.h @interface myFantasticViewController:UIViewController <UIAlertViewDelegate, UIGestureRecognizerDelegate, UITextFieldDelegate, UITextViewDelegate> -(void)handleUserDefinedStationWarning:(NSError *)error; myFantasticViewController.m -(void)handleUserDefinedStationWarning:(NSError *)error { NSString *errorMessage = [error localizedDescription]; UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"", @"Title for alert displayed when the user-defined station both lat/lon are zero.") message:errorMessage delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:@"Cancel", nil]; [alertView show]; } This is the code which triggers the alertview: NSString *message = [NSString stringWithFormat:@"Touch OK to continue without specifying the latitude and longitude."]; NSDictionary *userInfo = [NSDictionary dictionaryWithObject:NSLocalizedString(message, @"Message displayed when a user-defined station lat/lon are both zero.") forKey:NSLocalizedDescriptionKey]; NSError *error = [NSError errorWithDomain:@"myFantasticViewController" code:0000 userInfo:userInfo]; [self handleUserDefinedStationWarning:error]; ... some code ... these statements are executed immediately; the alertView pops up after the code is run which is causing the mayhem.
Has anybody got a clue as to what might be wrong? I have other alertViews in my app that work correctly.
HyperNova Software, LLC
     
Professional Poster
Join Date: Jan 2000
Location: Columbus, OH
Status: Offline
Reply With Quote
May 24, 2014, 01:32 PM
 
Problem solved.

The reason I was encountering all this grief was because the CPU was doing exactly what I told it to do.
I moved the code that was executing before the alertView displayed to within the clickedButtonAtIndex method.
I was not giving the OS time to display the alertView and was proceeding to do the intended code before the alertView had displayed.
HyperNova Software, LLC
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -4. The time now is 07:19 PM.
All contents of these forums © 1995-2014 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2014, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2