开发者

Move to another view when the user clicks on the OK button of the UIAlertView

开发者 https://www.devze.com 2023-03-07 05:35 出处:网络
When I display the alert to the user, if he clicked on the OK button I need to move h开发者_如何转开发im to another screen, how can I do that:

When I display the alert to the user, if he clicked on the OK button I need to move h开发者_如何转开发im to another screen, how can I do that:

UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"TopStation"
                                                message :@"Your internet connection is down, you will be redirected to the previous screen"
                                                delegate:nil
                                       cancelButtonTitle:@"OK"
                                       otherButtonTitles:nil];
    [alert show];
    [alert release];


What you'll need to do is implement the UIAlertView delegate in the method you are using.

So if you have the class

@interface MyClass: UIViewController {

You'll want to change it to use

@interface MyClass:UIViewController <UIAlertViewDelegate> {

Then in the implementation file you just need to implement the method

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

From there you can move on.

0

精彩评论

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