开发者

UIAlertView button option to open new view

I’m creating a tab based application. One of the tabs is test, and another of these tabs is results.

When the user has completed all the questions a UIAlertView message box pops up saying “Test Finished” and displays a “Ok” button to dismiss this message.

I’m wanting to change the title of this button to “Go to results” and can do this without any issues. But is there a way that enables me to direct the user to the results tab after clicking this message box butt开发者_Python百科on?

Any help would be appreciated. Thanks.


you have to set the selectedIndex of your UITabBarController

and you have to call this in the UIAlertViewDelegate method. So your method could look like this.

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
    if (buttonIndex == alertView.cancelButtonIndex) {
        // cancel... do nothing
    }
    else {
        AppDelegate_Shared *appDelegate = [[UIApplication sharedApplication] delegate];
        UITabBarController *tabBarController = appDelegate.tabBarController;
        [tabBarController setSelectedIndex:0];
    }
}

although, if you only have one button you don't need the if/else thingy.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜