|
|
UIAlertView delayed presentation
|
|
|
|
Professional Poster
Join Date: Jan 2000
Location: Columbus, OH
Status:
Offline
|
|
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.
|
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Jan 2000
Location: Columbus, OH
Status:
Offline
|
|
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|