嗨,
我正在尝试在我的iOS应用程序中实现方向旋转锁定/解锁切换开关。
锁定是可以的,但解锁是一个问题。
假设app的方向和设备的方向不同。如果用户在这种情况下解锁,app的方向应该立即跟随设备的方向。但是我找不到路。
如何模拟设备的方向旋转?
编辑
我会弄清楚情况的。
app中有一个切换开关,启用/禁用方向旋转。
一步一步:
对于每个orientation.,
除portlait外,
发布于 2012-06-28 18:00:38
我还没有尝试过,但是有一个viewController method attemptRotationToDeviceOrientation (iOS5)。也许值得一试。有趣的问题。如果它正常工作,请返回报告。
// call this method when your return value from shouldAutorotateToInterfaceOrientation: changes
// if the current interface orientation does not match the current device orientation,
// a rotation may occur provided all relevant view controllers now return YES from shouldAutorotateToInterfaceOrientation:
+ (void)attemptRotationToDeviceOrientation __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0);发布于 2012-10-23 23:03:56
在这里看我的答案:https://stackoverflow.com/a/13033443/580173
我制作了一个自定义的UINavigationController,您可以在那里检查您所处的视图,并使用正确的掩码进行响应。(我希望根视图是纵向的)
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
if([self.viewControllers count] == 1) return UIInterfaceOrientationMaskPortrait;
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscape;
}发布于 2012-06-28 18:07:19
您可以阅读“技术问答QA1688”,其中涉及自动转换,并在每个视图控制器中使消息shouldAutorotateToInterfaceOrientation:根据您的开关设置返回正确的值。您的info.plist中也有一个开关。Marke确保您在此处也有正确的设置
https://stackoverflow.com/questions/11241841
复制相似问题