Reputation: 71
i want common way of this in below code i used this code for ipad and iphone i don't want to use this Condition can anyone help me that i can't use this condition i want common code .. thanks in advance '
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
{
newSize = CGSizeMake(440.0, 440.0);
if (self.thumbnailImageView.frame.size.width == 440.0) {
newSize.width = 786.0;
newSize.height = 590.0;
}
}
else
{
newSize = CGSizeMake(190.0, 190.0);
if (self.thumbnailImageView.frame.size.width == 190.0) {
newSize.width = 320.0;
newSize.height = 340.0;
}
}
Upvotes: 3
Views: 108
Reputation: 214
If you are targeting iOS 8, I would recommend you take a look at the new size classes paradigm recently introduced. It abstracts out screen size and idiom and allows you to build view controllers that render correctly on iPhone or iPad, not depending on the device, but the size of the view.
For example, if you have a narrow list view that is displayed full screen on the iPhone, it can also be displayed in a popover or master (in master/detail) on the iPad. By defining the size class for the view controller, it will be displayed correctly on any device (including the iPhone 6 Plus, in landscape).
I recommend you watch the WWDC 2014 video on "Building Adaptive Apps with UIKit" for a more detailed explanation. https://developer.apple.com/videos/wwdc/2014/#216
Upvotes: 1