I am already trying it through the delegate method clickedButtonAtIndex: but I need to push a view through navigation controller as soon as the user presses “ok”…
I can’t allocate the view inside the method, Xcode doesn’t recognize the view controller’s name in the code. Any idea what I’m coin wrong?
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
switch(buttonIndex) {
case 0:
ReminderCompleted *view = [[ReminderCompleted alloc]initWithNibName:@"ReminderCompleted" bundle:nil];
[view.navigationController pushViewController:view animated:NO];
break;
case 1:
//cancel
break;
default:
break;
}
I get some errors
You cannot push a view, you can only push view controllers. You should be able to structure the code in a similar fashion, but instantiate a view controller (which can also use a nib) instead, and pass that to the navigation controller’s push method.Edit: Your variable name confused me, and you are indeed using a view controller. My suspect now is declaring a new variable inside of a switch, which Objective-C does not like. Try the same code, but declare the variable before the switch (you can leave it uninitialized until the right case happens).