在 iOS 中,手动旋转 View 的正确方法是什么?我有很多自定义旋转动画,但我根本不希望我的 View 自动旋转。
现在,我正在做这个......
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return interfaceOrientation == UIDeviceOrientationPortrait;
}
然后,我将执行此操作并根据需要响应方向变化:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];
一切工作正常,除了...当我尝试呈现操作表、MailViewController 等时,它们都以纵向显示:(
如何让我的 View 知道,虽然我不希望它自动旋转,但它实际上是在响应我手动处理的方向通知?
编辑:澄清一下,并不是我的旋转不起作用,而是当我呈现 UIActionSheet 时,它假设我必须处于纵向(即使我手动旋转,所以我不是),并且显示不正确。
最佳答案
手动旋转 View 时尝试使用[[UIApplication sharedApplication] setStatusBarOrientation:(UIInterfaceOrientation)];
关于ios - 手动旋转 UIView 而不是自动旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12679818/