shouldAutorotateToInterfaceOrientation在启动时调用两次

Raj*_*Raj 5 cocoa-touch objective-c screen-orientation uiinterfaceorientation ios

我正在开发iOS 5目标项目.我有如下定位方法.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{    
  NSLog(@" My Orientation");

  return YES;
}
Run Code Online (Sandbox Code Playgroud)

但是,当我的应用程序启动时,我的日志消息将在控制台上显示两次,即我Orientation将显示两次.我正在模拟器中测试我的应用程序,这只是在发布时发生,甚至没有更改orientation,然后再次更改方向.即

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
Run Code Online (Sandbox Code Playgroud)

每次被调用两次,我认为这不是一个正确的行为.任何帮助都是

赞赏.

Jos*_*iah 1

这不是你所做的任何事。苹果已经多次让设备对此做出反应。这仅取决于应用程序正在做什么。也许视图加载或其他原因导致它再次触发。然而,这真的是一个问题吗?在大多数情况下,它不是(或者至少不应该是)。

如果这确实是一个问题,那么也许有人应该详细说明。然而,至少从我的经验来看,这是常见的行为。我不知道有什么方法可以解决这个问题。

我想如果这真的让你烦恼并且没有办法解决,你可以向苹果提交一个错误。