I have been trying this one tonight for a while…. I have a UIActionSheet in its own controller. I import the controller in the view I would like it to be displayed. I can’t figure out how to make a new view be shown when the user presses one of the buttons (you can see where I just send an alert right now). Any ideas?
- (void)helpButtonPressedView {
// open a dialog with two custom buttons
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@""
delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil
otherButtonTitles:@"Help", @"Credits", nil];
[self parentViewController];
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
[actionSheet showInView:self.view]; // show from our table view (pops up in the middle of the table)
[actionSheet release];
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
NSLog(@"Button Pressed: %d",buttonIndex);
int btn = buttonIndex;
UIAlertView *alert;
switch (btn) {
case 0:
// help screen
alert = [[UIAlertView alloc] initWithTitle:@"Button Press Notice" message:@"The Help screen will be dispayed"
delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
[alert release];
// helpViewController = [[HelpViewController alloc] init];
// [self presentModalViewController:helpViewController animated:YES];
break;
case 1:
// credits screen
alert = [[UIAlertView alloc] initWithTitle:@"Button Press Notice" message:@"The Credits screen will be dispayed"
delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
[alert release];
break;
default:
break;
}
}
Here is a pic of what I am trying to do… When the user presses on the “Help” button, a new view shows. When the user presses the “Credits” button a different view shows. I am using IB to create the views.
It has been a while since I asked this question — and I figured it out a while ago…. I was missing the navigation controller to do a push of a view controller. In other words, create the view controller then push the view using a navigation controller. If anyone is reading this and needs sample code, post against the question and I will post the sample code…