我正在制作一个应用程序,我可以根据用户是否以纵向或横向模式移动他的 iPhone 来更改按钮布局。我认为放置我的代码的最佳位置是
-(BOOL) shouldautorotatetointerfaceorientation
但是这有两个主要问题
当页面加载时,应该至少调用 3 次autorotatetointerfaceorientation。我只想执行一次我的代码。
即使我使用 Modal segue 从 viewController1 (page1) 移动到 viewController2 (page2) 并在 page2 上旋转我的 iPhone,它仍然会调用我的 viewcontroller1 中的自动代码。那很奇怪。
无论如何,放置基于方向的图标的最佳位置是什么?
最佳答案
方法的唯一目的
-(BOOL) shouldautorotatetointerfaceorientation
用于确定支持哪些方向。
如果您希望对旋转执行自定义操作,那么您希望实现一个或两个方法
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation duration:(NSTimeInterval)duration
关于iphone - 检测iphone方向的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8826912/