开发者

Show UIAlertView on splash screen

I used to show a splash screen which in background load some data from web, I also check that if the location of the user is changed from one city to another city I want to show in alert to the user with the message that you are now in "CityName" would you like to see data from this city?

I have tabbed application and I have presented the splash screen as follow in the app delegate class.

SplashViewController *controller = [[SplashViewController alloc] initWithNibName:nil bundle:nil];
tabBarController.view.frame = [[UIScreen mainScreen] bounds];
controller.tabBarController = self.tabBarController;
[application setStatusBarStyle:UIStatusBarStyleBlackOpaque];
[window addSubview:controller.view ];
//[window addSubview:tabBarController.view ];

[self.tabBarController presentModalViewController:controller animated:YES];
[window makeKeyAndVisible];
[controller release];

Now when I show the alert screen it crash the application with "EXC_BAD_ACCESS" message and the stack trace show that _buttonClick is released in UIAlertView class.

Please advis开发者_StackOverflowe what should I do, I also tried with UIActionSheet but the same problem with this thing too.

I think there is some problem with the model thing with the current view (SplashView).

Thanks in advance.


Are you trying to display your UIAlertView inside of your SplashViewController viewDidAppear? If not, I would try that first. I would also make sure you have your UIAlertView clickedButtonAtIndex method setup properly to try and trap what is going on.

UIAlertView *alert = [[UIAlertView alloc] 
    initWithTitle:@"Your Location Has Changed" 
    message:@"Your location has changed since you last opened opened THEAPP. Would you like to refresh your data?" delegate:self 
    cancelButtonTitle:@"Cancel" 
    otherButtonTitles:@"OK", nil];
alert.tag = 1;
[alert show];
[alert autorelease];

Then for the clickedButtonAtIndex method:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {

    //--NSLog(@"You clicked button #%i",buttonIndex);

    if (alertView.tag == 1){

        if (buttonIndex == 0) {
            //--NSLog(@"CANCEL");

        } else if (buttonIndex == 1) {
            //--NSLog(@"OK");

        }
    }
}

Doing all of this on a splash screen should be fine as long as you take into account the HIG's requirements for using the users location. Hope this helps!


I resolve this issue, the problem was that my Splash View was a modeled view and invoked by

[self.tabBarController presentModalViewController:controller animated:YES];

what I did that I shifted the data downloading to another view controller and there I can show alerts, and can handle that

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜