ios - 即使不支持横向,也以横向模式显示 UIImage

标签 ios objective-c uiimageview uiimage orientation

即使我不支持横向(在项目设置中停用),iOS 中是否有办法自动将设备切换为横向模式?

我有一些图片。如果用户点击其中一张图像,该图像将以全屏显示,并使用内容模式 UIViewContentModeScaleAspectFit 来保持宽高比。现在我所有的图像都比高度宽,所以我认为当图像全屏显示时设备切换到横向模式会更好。

如果我停用了横向模式,这可能吗?或者是否有解决方法,例如将图像和导航栏旋转 90 度或其他?

最佳答案

试试这个,

if (self.interfaceOrientation != UIInterfaceOrientationLandscapeRight) {

    [[UIDevice currentDevice] performSelector:NSSelectorFromString(@"setOrientation:") withObject:(id) UIInterfaceOrientationLandscapeRight];
}

关于ios - 即使不支持横向,也以横向模式显示 UIImage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25308678/

相关文章:

Apple 代码中的 iPhone 内存泄漏

ios - 如何对齐 imageView 内的图像

php - 显示图像而不是变量值

ios - iOS 应用程序如何知道何时下载新数据?

ios - 使用Automation Instrument时如何清除Editor log和Trace Log

ios - 为什么在使用GCD时出现错误EXC_BAD_INSTRUCTION(代码= EXC_I386_INVOP,子代码= 0x0)

ios - UITableViewCell 中的圆形图像

ios - UIPageViewController自定义PageControl

ios - iOS 设备未收到 Urban Airship iOS 推送通知

ios - 我想将 Table View 精确放置到导航栏