- (void)viewDidLoad{
[super viewDidLoad];
// I put self in a Navigation VC so we can use its right navigationbar
// item for triggering the transition
self.navigationItem.rightBarButtonItem =
[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit
target:self
action:@selector(button:)]
autorelease];
// create test1 and test2 instance (subclass UIViewController and
// also need to define their own nibs)
vc1 = [[test1 alloc]initWithNibName:@"test1" bundle:nil];
vc2 = [[test2 alloc]initWithNibName:@"test2" bundle:nil];
//add to the container vc which is self
[self addChildViewController:vc1];
[self addChildViewController:vc2];
//the entry view (will be removed from it superview later by the api)
[self.view addSubview:vc1.view];
}
IBAction này kích hoạt quá trình chuyển đổi giữa hai VC:
-(IBAction)button:(id)sender {
[self transitionFromViewController:vc1
toViewController:vc2
duration:0.5
options:UIViewAnimationOptionTransitionCurlDown
animations:nil
completion:nil];
}