[英]How to rotate a photo on iPhone only?
I have an iPhone app I am testing on my iPhone and iPad.我有一个 iPhone 应用程序,正在我的 iPhone 和 iPad 上进行测试。 When running my app adhoc, the problem is that when the photo loads on my iPhone 4 during ad hoc testing, the photo loads on its side;
在临时运行我的应用程序时,问题是在临时测试期间照片加载到我的 iPhone 4 上时,照片在其一侧加载; the photo loads fine on iPad mini.
照片在 iPad mini 上加载良好。
The following line of code successfully rotates the fullscreen image on iPhone, but conversely rotates the image when I test on iPad.以下代码行在 iPhone 上成功旋转了全屏图像,但在 iPad 上测试时反过来旋转了图像。
//successfully rotates but also over rotates on iPad
PhotoView.transform=CGAffineTransformMakeRotation(M_PI*0.5);
Can someone help me set up conditional statements so I can use my CGAffineTransforMakeRotation
line of code only on iPad?有人可以帮我设置条件语句,以便我只能在 iPad 上使用我的
CGAffineTransforMakeRotation
代码行吗?
I have so far tried the following conditional statements but they don't work for some reason: ie only the iPhone if statement works and overrides the iPad if statement so the iPhone statement is carried out on both devices.到目前为止,我已经尝试了以下条件语句,但由于某种原因它们不起作用:即只有 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){
}
This second conditional statement also doesn't work...这第二个条件语句也不起作用......
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
}
My question: does anyone have code to rotate an image on iPhone but not iPad?我的问题:有没有人有代码可以在 iPhone 上旋转图像而不是 iPad?
If it's an iPhone app, it is always "on an iPhone".如果它是一个 iPhone 应用程序,它总是“在 iPhone 上”。 Even when running on the iPad, it is running on a virtual iPhone in emulation mode.
即使在 iPad 上运行,它也是在模拟模式下在虚拟 iPhone 上运行。 It is impossible for it to behave differently on the different devices;
它不可能在不同的设备上表现不同; it is running on just one device type, as far as it can tell.
据它所知,它仅在一种设备类型上运行。
If you don't like that, make it a Universal app.如果您不喜欢那样,请将其设为通用应用程序。 Now it runs natively on iPad and your tests will work.
现在它可以在 iPad 上本地运行,并且您的测试将起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.