我有一個我爲3.5和4英寸設計的應用程序。我調整了以下方法在屏幕上的項目:nativeScale - >在3.5英寸iPhone 4S上崩潰
CGRect screenBounds = [[UIScreen mainScreen] bounds];
if (screenBounds.size.height == 568) {
//4 inch code
} else {
//3.5 inch code
}
那麼iPhone 6和6以及所發佈的,所以我不得不調整自己的screensizes爲好。幸運的是iPhone 6具有相同的縮放比例,因此可以使用相同的方法。但是當涉及到iPhone 6+時,它不再起作用,因爲它是一個3x規模。
現在,這就是爲什麼我改變了我的方法,我以前用過,到:
CGRect screenBounds = [[UIScreen mainScreen] bounds];
if ([UIScreen mainScreen].nativeScale > 2.1) {
//6 plus
} else if (screenBounds.size.height == 568) {
//4 inch/iPhone 6 code
} else {
//3.5 inch code
}
現在,在所有設備上,但iPhone 4S的完美的作品。它崩潰。日誌說:
2014-10-17 21:06:31.370 Lichtpunkt[1288:60b] -[UIScreen nativeScale]: unrecognized selector sent to instance 0x17539920 2014-10-17 21:06:31.372 Lichtpunkt[1288:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIScreen nativeScale]: unrecognized selector sent to instance 0x17539920' *** First throw call stack: (0x30b94fd3 0x3b40dccf 0x30b98967 0x30b97253 0x30ae67b8 0x4102b 0x3342fda5 0x3305d2c1 0x33046e3f 0x33121d6d 0x330466f3 0x3304639b 0x3302a03d 0x33029cd5 0x330296df 0x330294ef 0x3302321d 0x30b602a5 0x30b5dc49 0x30b5df8b 0x30ac8f0f 0x30ac8cf3 0x35a21663 0x3341416d 0x18d6b91 0x2c9d1 0x3b91aab7) libc++abi.dylib: terminating with uncaught exception of type NSException
而問題是,我不能恢復的變化,因爲iPhone 6+ 1號溶液然後沒有完全調整,我試過了。
任何人都可以幫助我嗎?
如果你可以用AutoLayout處理所有這些,不是很好嗎? – 2014-10-18 04:29:52
@MichaelDautermann以及它肯定會,但它不工作,因爲我有一個scrollView與imageView裏面和zoomFactors不適合autoLayout – LinusGeffarth 2014-10-18 04:31:11