ビューアニメーションを使用してビューを切り替えていますが、インターフェイスの向きに問題があります。
ウィンドウには2つのビューがあります。
- 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
ですか?