Is it possible to show/hide buttons depending on if the user is using 3.5 inch or 4 inch?
For example, if the view controller is loaded with 3.5 inch the button is hidden, and if it is loaded with a 4.0 inch device the button is shown?
Is it possible to show/hide buttons depending on if the user is using 3.5 inch or 4 inch?
For example, if the view controller is loaded with 3.5 inch the button is hidden, and if it is loaded with a 4.0 inch device the button is shown?
You can't get the physical size of the screen, but you can get its resolution. The 4" iPhone 5 and the new iPod touch have 320×568 points, while the other iPhones have 320×480. You can get these dimensions using [[UIScreen mainScreen] bounds].size
.
It's of course possible that Apple releases a new phone that has the same pixel dimensions as the 4" iPhone 5, but uses a 5" (or whatever) screen, or that they release a device that has completely different dimensions. Your code should ideally be prepared for that, and not make the assumption that these dimensions are set in stone. On the other hand, this kind of change typically doesn't happen overnight.
So, if you want to hide a button on devices with "small" screens, you could do something like this:
- (void)viewDidLoad {
self.myButton.hidden = [[UIScreen mainScreen] bounds].size.height <= 480;
}