我在视图之间切换使用视图动画,其作品,但我有一个接口方向的问题。interfaceorientation保持相同removeFromSuperview并再次addSubview
我在窗口上有两个视图。
- authenticationViewCont
- mainViewCont
两者有一个按钮,当按钮点击authenticationViewCont
我将其删除,并显示mainViewCont
,反之亦然。
一旦我addSubview的authenticationViewCont.view
并把设备处于纵向模式然后通过removeFromSuperview
删除它,然后我在我的手里更改设备方向为横向,然后再addSubview的authenticationViewCont
。它首先在肖像中显示动画并在动画之后改变方向。
-(void)mainToAuthentication {
CGRect originalFrame = authenticationViewCont.view.frame;
CGRect modifiedFrame = originalFrame;
modifiedFrame.origin.y = originalFrame.size.height;
// made view out from screen
authenticationViewCont.view.frame = modifiedFrame;
// add sub view on top of other views
[self.window addSubview:authenticationViewCont.view];
// transiting view from bottom to center of screen
[UIView animateWithDuration:0.5
animations:^{ authenticationViewCont.view.frame = originalFrame; }
completion:^(BOOL finished){ mainViewCont.view removeFromSuperview; }];
}
-(void)authenticationToMain {
CGRect originalFrame = mainViewCont.view.frame;
CGRect modifiedFrame = originalFrame;
modifiedFrame.origin.y = -originalFrame.size.height;
// made view out from screen
mainViewCont.view.frame = modifiedFrame;
// add sub view on top of other views
[self.window addSubview:mainViewCont.view];
// transiting view from top to center of screen
[UIView animateWithDuration:0.5
animations:^{ mainViewCont.view.frame = originalFrame; }
completion:^(BOOL finished){ authenticationViewCont.view removeFromSuperview; }];
}
我怎样才能使其在当前界面的方向,而不是旧的接口方位上是removeFromSuperview
显示?