I am trying to hide a button on certain devices. Is there a 'if' statement i could use or something?
thanks in advance
I am trying to hide a button on certain devices. Is there a 'if' statement i could use or something?
thanks in advance
Not sure if you can detect specific device, but you can always categorise based on sizes using [[UIScreen mainScreen] bounds].size.height
.
You can check for the heights and decide the class of device
if([[UIDevice currentDevice]userInterfaceIdiom]==UIUserInterfaceIdiomPhone)
{
if ([[UIScreen mainScreen] bounds].size.height > 666.0f) {
//iphone 6/6+
}
else if ([[UIScreen mainScreen] bounds].size.height == 568.0f)
{
//iPhone 5/5C/5S
}
else
{
//iphones of lower height(3GS/4/4S)
}
}
else
{
// its an iPad
}
Yes there is. You can get the current device by calling [UIDevice currentDevice]
.
Here is the class documentation
There are methods for specific iOS versions, models, or you can distinguish between iPad and iPhone. Here is some example code I have in one of my projects.
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
//Do stuff for iPad
}