我正在尝试实现viewWillTransitionToSizeiOS 8中引入的新方法(所有其他旋转方法已被弃用).我想知道现在的等价物didRotateFromInterfaceOrientation是什么,因为我们需要执行许多清理任务,我无法看到我们可以指定的块,UIViewControllerTransitionCoordinator以便在"转换"为新的时调用大小完成.谢谢.
我有一个关于如何在iOS上检测设备方向的问题.我不需要接收更改通知,只需要接收当前方向.这似乎是一个相当简单的问题,但我无法绕过它.以下是我到目前为止所做的事情:
UIDevice *myDevice = [UIDevice currentDevice] ;
[myDevice beginGeneratingDeviceOrientationNotifications];
UIDeviceOrientation deviceOrientation = myDevice.orientation;
BOOL isCurrentlyLandscapeView = UIDeviceOrientationIsLandscape(deviceOrientation);
[myDevice endGeneratingDeviceOrientationNotifications];
Run Code Online (Sandbox Code Playgroud)
在我看来这应该工作.我启用设备接收设备方向通知,然后询问它的方向,但它不起作用,我不知道为什么.
在iOS 8上运行,我需要在旋转我的应用程序时更改UI.
目前我正在使用此代码:
-(BOOL)shouldAutorotate
{
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if (orientation != UIInterfaceOrientationUnknown) [self resetTabBar];
return YES;
}
Run Code Online (Sandbox Code Playgroud)
我这样做删除了当前的UI并添加了一个适合方向的新UI.但是,我的问题是,每次进行一次旋转时,此方法被调用大约4次.
在iOS 8中对方向更改进行更改的正确方法是什么?
我正在研究使用故事板为我的应用程序启动图像.该应用程序始终使用大型照片作为启动图像,该照片也用作第一个视图的背景.但是,当应用程序在iPad上以横向方式启动时,图像会有所不同.
那么在使用自适应故事板作为发布屏幕时,有没有办法区分纵向iPad和横向iPad?因为它是一个启动屏幕,我不能运行任何代码,它必须完全通过故事板完成.
我使用以下代码查看设备是否处于横向模式:
UIDevice.currentDevice().orientation.isLandscape.boolValue
Run Code Online (Sandbox Code Playgroud)
但是,如果我在启动应用程序之前将设备置于横向模式,则可以正常工作,之后再viewDidLoad调用此代码行,则始终返回false。
如果我改用这个:
interfaceOrientation.isLandscape
Run Code Online (Sandbox Code Playgroud)
它返回true,这是正确的,但是编译器正在显示警告interfaceOrientation was deprecated in iOS 8.0。
启动应用后立即获得设备定位的正确方法是什么?
ios ×4
objective-c ×3
orientation ×3
ios8 ×2
adaptive-ui ×1
iphone ×1
swift ×1
swift2 ×1
uidevice ×1