ビューの回転を1つのビューコントローラーのみに制限する方法はありますか?たとえば、アプリの残りの部分はポートレートモードのままですが、1つのビューをランドスケープモードまたはポートレートモードにすることができます。
2 に答える
3
このデリゲートメソッドを使用して、回転を制御します。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
// Return YES for supported orientations
return YES;
}
else
{
return NO;
}
}
サポートしたいオリエンテーションにはYESを返し、他のオリエンテーションにはNOを返します。これは、すべてのViewControllerに実装できます。
于 2011-10-28T03:36:13.483 に答える
1
shouldAutorotateToInterfaceOrientation:
それぞれのメソッドを実装できますUIViewController
。特定のビューコントローラでサポートする方向に戻るYES
と、目的の結果が得られます。
UIViewControllerのドキュメントを参照してください。
于 2011-10-28T03:38:20.513 に答える