First we put a button there and correspond it to a method called nextPage.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
- (void)viewDidLoad { [super viewDidLoad]; [self.view setBackgroundColor:[UIColor greenColor]]; //[self.navigationController pushViewController:bookCoverViewController animated:YES]; //add back button UIButton * couponButton = [UIButton buttonWithType: UIButtonTypeCustom]; //auto-released couponButton.userInteractionEnabled = YES; [couponButton setTitle:@"Next Page" forState:UIControlStateNormal]; couponButton.frame = CGRectMake(367, 100, 64, 64); [couponButton.titleLabel setFont:[UIFont boldSystemFontOfSize:12.0f]]; [couponButton addTarget:self action: @selector(nextPage) forControlEvents: UIControlEventTouchUpInside]; [self.view addSubview: couponButton]; // Uncomment the following line to preserve selection between presentations. // self.clearsSelectionOnViewWillAppear = NO; // Uncomment the following line to display an Edit button in the navigation bar for this view controller. // self.navigationItem.rightBarButtonItem = self.editButtonItem; } |
Then in that method, you use pushViewController to animate a new controller coming in.
1 2 3 4 5 6 |
-(void)nextPage { MTBookCoverViewController * bookCoverViewController = [[MTBookCoverViewController alloc] init]; [self.navigationController pushViewController:bookCoverViewController animated:YES]; [bookCoverViewController release]; } |
…where MTBookCoverViewController is just a standard, empty UIViewController.