Is there any better code so we can't use the condition for a generic app

I need a general way of doing this in the below code. I have used this code for ipad and iphone. I don't want to use this condition. Can anyone help me with the fact that I cannot use this condition, I want generic code.

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;

  }
}

      

+3


source to share


1 answer


If you are targeting iOS 8, I would recommend that you take a look at the newly emerging size class paradigm. It abstracts away screen size and idiom and allows you to create view controllers that render correctly on an iPhone or iPad, no matter the device, but the view size.

For example, if you have a narrow list view that is displayed full screen on the screen on an iPhone, it can also appear in a popover or master (in master / detail) on an iPad. By defining a size class for the view controller, it will display correctly on any device (including the iPhone 6 Plus, in landscape orientation).



I recommend you watch the WWDC 2014 video on "Building Responsive Apps with UIKit" for a more in-depth explanation. https://developer.apple.com/videos/wwdc/2014/#216

+1


source







All Articles