开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜