I know the in objective-c, there is a way to know which device the user is using. But I really a new of iOS development, I do not know those complex and complicated command in objective-c. Could any one tell me how to identify the phone model by coding.
Also, if I can know which device the user is using, is that possible to change the UILabel in different font size in different iOS device, such as iPhone 3.5" and iPhone 4.0"? Or is there any way to change the font position in different iOS device (autolayout is disabled)?
The way I determine what iOS device I am running on so we can change layout based on the iDevices size such as
iPad
andiPhone
is like.To get
iPhone 5
you could also doI add these into my
xxxx-Prefix.pch
so that I can use it throughout my project without having to do an#import
or#include
. I am not saying this is the best way but this way works perfectly fine for me.If you set these variables you can then just use
if statements
likeThere are other ways of doing it though. Such as one developer has written some code that extends
UIDevice
this can be found https://github.com/erica/uidevice-extension/This will allow you to detect whether the iDevice is an
iPhone 3
,3GS
,4
and so on.If you have any questions please just ask in the comments and I will improve my answer to include. Hope it helps if it has here is a google search for determining iDevice
You can use the below code to differentiate the devices based on the screen size and use it to change UILabel frame, font size etc...