繁体   English   中英

如何仅在 iPhone 上旋转照片?

[英]How to rotate a photo on iPhone only?

我有一个 iPhone 应用程序,正在我的 iPhone 和 iPad 上进行测试。 在临时运行我的应用程序时,问题是在临时测试期间照片加载到我的 iPhone 4 上时,照片在其一侧加载; 照片在 iPad mini 上加载良好。

以下代码行在 iPhone 上成功旋转了全屏图像,但在 iPad 上测试时反过来旋转了图像。

//successfully rotates but also over rotates on iPad
PhotoView.transform=CGAffineTransformMakeRotation(M_PI*0.5);

有人可以帮我设置条件语句,以便我只能在 iPad 上使用我的CGAffineTransforMakeRotation代码行吗?

到目前为止,我已经尝试了以下条件语句,但由于某种原因它们不起作用:即只有 iPhone if 语句有效并覆盖 iPad if 语句,因此 iPhone 语句在两个设备上都执行。

//does not successfully set the bk for iPad but does for iPhone. The iPad statement is overridden and the iPhone statement is carried out on both platforms. Any ideas?

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad){
}
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
}

这第二个条件语句也不起作用......

if ([[UIScreen mainScreen] bounds].size.height == 480)
    {
        // iPhone, iPod Touch
    }
    if ([[UIScreen mainScreen] bounds].size.height == 568) {
        // iPhone 5
    }
    if ([[UIScreen mainScreen] bounds].size.height ==  667) {
        // iP6
    }
    if ([[UIScreen mainScreen] bounds].size.height ==  736) {
        // iP6+
    }
    if ([[UIScreen mainScreen] bounds].size.height == 1024) {
        // iPad
    }

我的问题:有没有人有代码可以在 iPhone 上旋转图像而不是 iPad?

如果它是一个 iPhone 应用程序,它总是“在 iPhone 上”。 即使在 iPad 上运行,它也是在模拟模式下在虚拟 iPhone 上运行。 它不可能在不同的设备上表现不同; 据它所知,它仅在一种设备类型上运行。

如果您不喜欢那样,请将其设为通用应用程序。 现在它可以在 iPad 上本地运行,并且您的测试将起作用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM