Posted By

espinallab on 04/14/11


Tagged


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

mirage3d
cnathan
dvel


Easy way for Checking Device Type


 / Published in: Objective C
 

  1. //Place this in the .m file outside any function.
  2.  
  3. BOOL isiPhone(){
  4. return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone);
  5. }
  6. BOOL isiPad(){
  7. return (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPhone);
  8. }
  9.  
  10.  
  11. //Then call it from any function like this:
  12. if (isiPhone()) {
  13. //This device is an iphone
  14. }
  15.  
  16. if (isiPad()) {
  17. //This device is an iPad
  18. }

Report this snippet  

You need to login to post a comment.