Question

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.

Was it helpful?

Solution

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];
}

OTHER TIPS

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;
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top