2

I know thinks about size class, but here I don't know how to do, on my menu I wan't to have a bigger row height size on iPad than iPhone.

Here I can set the row height:

enter image description here

But I don't see how to use size class here to have a different height between different devices.

Ben
  • 761
  • 1
  • 12
  • 35

2 Answers2

6

If doing it in the code is an option, you could do something like this in viewDidLoad:

if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
    tableView.rowHeight = 100;
}
else {
    tableView.rowHeight = 44;
}

it should work on iOS 3.2 and above, so basically anything you can realistically target.

ishaq
  • 1,781
  • 1
  • 11
  • 19
  • 1
    As per my info this method is available in ios 3.2 and above.. (please confirm again) @ishaq – Fayza Nawaz Jan 25 '16 at 14:45
  • @FayzaNawaz you are talking about `UI_USER_INTERFACE_IDIOM` macro, `userInterfaceIdiom` method is different from that. please see: http://stackoverflow.com/questions/29608613/how-can-i-detect-if-device-is-an-ipad-in-ios-8-3 – ishaq Jan 25 '16 at 14:47
  • 1
    i'm checking the documentation and have found this in UIKit->UIDevice: @available(iOS 3.2, *) public var userInterfaceIdiom: UIUserInterfaceIdion {get} P.S. i'm working in swift and my app supports iOS 7.1+. I'm using this without any issue (and i know it's not a function but works for the same thing) – Fayza Nawaz Jan 25 '16 at 14:52
  • I stand corrected :-) have edited my answer to reflect this. – ishaq Jan 25 '16 at 14:54
  • Can we detect iphone 4 ... to 6 ? – Ben Jan 26 '16 at 08:27
  • there isn't an out of the box method to do it, you'll need to check screen size. details here: http://stackoverflow.com/questions/12446990/how-to-detect-iphone-5-widescreen-devices , but if you are going there, it would be much better to use size classes instead of this answer. – ishaq Jan 26 '16 at 09:27
0

In Swift Use:

if(UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.pad){
            return 500
        }
        else {
            return 200
        }
Swapna Lekshmanan
  • 514
  • 10
  • 30