iphone: change content of a view with Animation
I need help on this thing. I 开发者_StackOverflow社区have 3 view controllers say Parent and Child1, Child2
in Parent viewcontollers I have a view called container and a segmented control.
Now I want that content of this 'container' view change with animation everytime the value of segmented control is changed.
I have done till here please tell me what needs to be added:
if (selectSearchType.selectedSegmentIndex==0) {
[aAdvanceSearchViewContoller.view removeFromSuperview];
[container addSubview:aBasicSearchViewController.view];
}else {
NSLog(@"Advance Search");
[aBasicSearchViewController.view removeFromSuperview];
[container addSubview:aAdvanceSearchViewContoller.view];
}
Add the following lines to your code:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:myview cache:YES];
[myview removeFromSuperview]; //remove or addSubview as required
[UIView commitAnimations];
精彩评论