0

我想shouldAutorotateToInterfaceOrientation在 UIViewController 中调用函数之前进行一些初始化。然而,在不同的函数中添加一些打印输出之后,这些函数显然被调用的顺序如下:

1.-shouldAutorotateToInterfaceOrientation

2.-loadView

3.-viewDidLoad

4.- shouldAutorotateToInterfaceOrientation(再次)

5.-viewWillAppear

...

init此外,这些函数initWithNibName永远不会被调用(或者至少我永远不会得到打印输出)。

我认为initor initWithNibName(取决于您使用的方法)应该在之前调用shouldAutorotateToInterfaceOrientation。但我想我错了(或者我做错了什么?)。也许这是因为这个视图控制器在故事板编辑器中被标记为“是初始视图控制器”?

无论如何,之前shouldAutorotateToInterfaceOrientation在 UIViewController 中自动调用的函数是什么?

太感谢了!

注意:我知道shouldAutorotateToInterfaceOrientation自 6.0 以来已过时,但我希望我的应用程序也与 5.0 兼容。

编辑:我只想在之前初始化一些变量shouldAutorotateToInterfaceOrientation,而且我只想这样做一次,而不是每次都shouldAutorotateToInterfaceOrientation被调用。

4

1 回答 1

0

shouldAutorotateToInterfaceOrientation您可以在返回之前YESNO通过覆盖此方法进行任何您需要做的设置:

在您的实施中:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  // do whatever is needed before the rotation actually happens

  return YES;
}
于 2013-01-28T18:14:43.253 回答