How To Differentiate Betwixt 3.5 Together With Four Inch Iphone

Open Xcode in addition to practice a novel Single View Application. For production name, utilisation DifferentiateIphoneSize in addition to thus fill upwards out the Organization Name in addition to Company Identifier alongside your customary values. Select iPhone for Devices.



For demonstration purposes, add together a label within the persuasion controller in addition to alter the text to "3.5-inch or 4-inch".

We volition remove to connect the label to the persuasion controller. Select the assistant editor in addition to opened upwards the ViewController.m file. Ctrl in addition to drag from the label to the cast department in addition to practice the next outlet.



Inside the viewDidLoad, add together the next lines of code:
      if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {         if ([[UIScreen mainScreen] scale] == 2.0) {             if([UIScreen mainScreen].bounds.size.height == 568){                 // iPhone retina-4 inch                 self.lbl_textOutput.text = @"iPhone retina-4 inch";             } else{                 // iPhone retina-3.5 inch                 self.lbl_textOutput.text = @"iPhone retina-3.5 inch";             }         }         else {             // non retina display             self.lbl_textOutput.text = @"iPhone that's non retina display";         }     }  
Build in addition to Run, a label tin move seen alongside text "iPhone retina-4 inch" if the app is operate inwards alongside 4-inch size, otherwise "iPhone retina-3.5 inch".


You tin download the root code of the DifferentiateIphoneSize at my repository on bitbucket.
Next
Previous
Click here for Comments

0 komentar:

Please comment if there are any that need to be asked.