开发者

How to make Action Sheet button open new view

I have an iPhone app that uses an action sheet but I can't work out how to make one of the buttons open a new view when pressed. I know how to implement the action sheet - that's not a problem, its the actual action of opening the new view that's 开发者_运维知识库the issue.

Any help would be greatly appreciated. Thanks.


I usually just create a new method and have the action sheet do it.

For instance:

switch (buttonIndex) {
    case 0:
        [self openModalView];
        break;
 }

Then, in your openModalView method:

- (void)openModalView {
    MyModalViewController *myController = [[MyModalViewController alloc] init];
    [self presentModalViewController:myController animated:YES];
    [myController release];
}


In the UIAlertView's -didDismissWithButtonIndex, instantiate your new view controller and push it onto the navigation stack:

- (void)alertView:(UIAlertView *)alertView 
                 didDismissWithButtonIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 0)
    {
        NewViewController *controller = [[NewViewController alloc] init];
        [[self navigationController] pushViewController:controller animated:YES];
        [controller release], controller = nil;
    }
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜