开发者

Is there a way to call a function when the interface rotates in Iphone?

开发者 https://www.devze.com 2022-12-27 16:45 出处:网络
When my interface rotates i want to call certain functions. How can I do the开发者_开发知识库se actions?Depending on what you want to do,

When my interface rotates i want to call certain functions. How can I do the开发者_开发知识库se actions?


Depending on what you want to do,

Implement some of these methods in your active view controller class:

  • -willRotateToInterfaceOrientation:duration:
  • -willAnimateRotationToInterfaceOrientation:duration:
  • -didRotateFromInterfaceOrientation:

Or some of these methods in your app delegate:

  • -application:willChangeStatusBarOrientation:duration:
  • -application:didChangeStatusBarOrientation:

Or listen to some of these local notifications:

  • UIApplicationWillChangeStatusBarFrameNotification
  • UIApplicationDidChangeStatusBarFrameNotification
  • UIApplicationWillChangeStatusBarOrientationNotification
  • UIApplicationDidChangeStatusBarOrientationNotification


You can use this:

   [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号