アプリケーションにビューがあります。横向きで表示したい特定のビュー。ユーザーがそのビューに来たら、ユーザーにデバイスの向きを変更するように強制したいと思います。ユーザーが他のビューに移動すると、tiをリセットする必要があります。どうすればいいですか?
2 に答える
3
ビューコントローラでは、2つのメッセージを実装します。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
そしてそれがすべてです。
于 2012-10-08T09:08:39.850 に答える
1
答えがわかりました
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
float angle = M_PI/2; //rotate 180°, or 1 π radians
self.view.layer.transform = CATransform3DMakeRotation(angle, 0, 0.0, 1.0);
于 2012-10-08T09:13:14.027 に答える