Objective-C:How to define CELL_CONTENT_WIDTH for both iPhone and iPad?-Collection of common programming errors
If you have a universal app, then you differentiate between the iPad and the iPhone at build time. So you can’t make #defines with different values for the two devices.
However you can determine the type of the device at runtime using UI_USER_INTERFACE_IDIOM():
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
// iPhone
// ...
} else {
// iPad
// ...
}
320 is also the width of the iPhone screen. So if you want your cells to have the width of the device screen, you can determine that like this:
CGFloat width = [UIScreen mainScreen].bounds.size.width;