self.interfaceOrientation导致在iOS 4.x上调用shouldAutorotateToInterfaceOrientation

时间:2012-10-03 07:24:24

标签: iphone ios uiviewcontroller ios4 autorotate

当我在模拟器或设备中测试4.x下的单视图应用时,启动时主UIViewController的shouldAutorotateToInterfaceOrientation:方法被精确调用3046次(在设备上)或23777次(在模拟器上)然后崩溃。 ... ...更新

更新:我所拥有的方法 UIInterfaceOrientation currentOrientation = self.interfaceOrientation;

这似乎是罪魁祸首,它导致shouldAutorotateToInterfaceOrientation:再次被调用,因此将其置于无限循环中直至崩溃。谁知道为什么?它在iOS 5+中没有这样做

1 个答案:

答案 0 :(得分:1)

如果您需要对Orientation change事件进行任何处理,请改用此方法,

 - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
 {
    [self HandleOrientationChange:toInterfaceOrientation];
 }

 -(void) HandleOrientationChange:(UIInterfaceOrientation) orientation
  {}