LoginSignup
9
8

More than 5 years have passed since last update.

iPhoneの回転時のアニメーションを止める方法

Posted at

iPhone等のデバイスを回転した時、拡張キーボードを縦横で変更するようにしていたりすると、アニメーションがガチャガチャして格好が悪くなります。そのような場合にアニメーションをさせないようにして誤魔化す方法です。副作用として動作がキビキビになります:-)

ObjectiveC
@interface ViewController : UIViewController
@end

@implementation ViewController
static BOOL needRevert;
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    needRevert = [UIView areAnimationsEnabled];
    [UIView setAnimationsEnabled:NO];
}

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
    if (needRevert) [UIView setAnimationsEnabled:YES];
}
@end
9
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
8