iphone:使用动画更改视图的内容

Ank*_*han 0 iphone objective-c uiview ipad

我需要这方面的帮助.我有3个视图控制器,表示Parent和Child1,Child2

在父viewcontollers我有一个名为容器和分段控件的视图.

现在,每当分段控件的值发生变化时,我希望这个"容器"视图的内容随动画而变化.

我已经做到这里,请告诉我需要添加什么:

if (selectSearchType.selectedSegmentIndex==0) {



    [aAdvanceSearchViewContoller.view removeFromSuperview];
    [container addSubview:aBasicSearchViewController.view];

}else {
    NSLog(@"Advance Search");
    [aBasicSearchViewController.view removeFromSuperview];
    [container addSubview:aAdvanceSearchViewContoller.view];
}
Run Code Online (Sandbox Code Playgroud)

HG'*_*G's 5

将以下行添加到您的代码中:

[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];
Run Code Online (Sandbox Code Playgroud)