0

iOS で、ビューを手動で回転させる適切な方法は何ですか? カスタム回転アニメーションがたくさんありますが、ビューを自動回転させたくありません。

いま、こんなことをしている...

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return interfaceOrientation == UIDeviceOrientationPortrait;
}

次に、これを行い、必要に応じて向きの変更に対応しています。

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];

アクションシート、MailViewControllerなどを表示しようとすると、すべて縦向きで表示されます:(

ビューを自動回転させたくないのに、実際には手動で処理している方向通知に応答していることをビューに知らせるにはどうすればよいですか?

編集: 明確にするために、回転が機能していないわけではありません。UIActionSheet を提示すると、縦向きである必要があると想定され (手動で回転していない場合でも)、正しく表示されません。 .

4

3 に答える 3

1

[[UIApplication sharedApplication] setStatusBarOrientation:(UIInterfaceOrientation)];ビューを手動で回転するときに使用してみてください

于 2012-10-08T09:38:50.550 に答える
0

shouldAutorotateToInterfaceOrientation 内からメソッドを呼び出すことができるかもしれません。例えば:

    - (BOOL)shouldAutorotateToInterfaceOrientation (UIInterfaceOrientation)interfaceOrientation
{
    if (interfaceOrientation != UIDeviceOrientationPortrait)
        [self theActionYouWantToPerform]

    // Return YES for supported orientations
    return interfaceOrientation == UIDeviceOrientationPortrait;
}
于 2012-10-01T20:47:33.913 に答える