{"id":1772,"date":"2011-02-05T21:49:56","date_gmt":"2011-02-05T16:49:56","guid":{"rendered":"http:\/\/aasims.wordpress.com\/?p=1772"},"modified":"2025-04-27T19:49:00","modified_gmt":"2025-04-27T19:49:00","slug":"iphoneipad-development-tips-n-faq","status":"publish","type":"post","link":"https:\/\/aasimnaseem.com\/blog\/iphoneipad-development-tips-n-faq\/","title":{"rendered":"Code Chunks &#8211; iOS"},"content":{"rendered":"<p>Hello Everyone;\u00a0 Hope weekend is going well.<\/p>\n<p>Today&#8217;s menu is really simple; I will give you some tips regarding iPhone application development. I used them recently, so want to share with you people. Here they are.<\/p>\n<p><strong>1. Screen Resolution<\/strong><\/p>\n<p>At the time of this post, the iPhones are available in different screen resolutions: 320\u00d7480, and the iPhone 4 screen resolution is 640&#215;960. The same is the case for the iPad; currently it is 1024&#215;768, and the iPad 2 is likely to have 2048&#215;1536 screen resolution. So we need to care about this while playing with layouts. Here is a code to determine screen size:<!--more--><\/p>\n<p>[sourcecode language=&#8221;objc&#8221;]<\/p>\n<p>CGRect currentScreen = [[UIScreen mainScreen] bounds];<br \/>\ncurrentScreen.size.width; \/\/ will return the width of screen;<br \/>\ncurrentScreen.size.height \/\/ will return height of screen;<br \/>\n[\/sourcecode]<\/p>\n<p>Note: If you rotate your screen to landscape, then height will become width and vise versa;<\/p>\n<p><strong>2. Device Type;<\/strong><\/p>\n<p>Following piece of code will tell you whether your application is running on iPhone or iPad;<\/p>\n<p>[sourcecode language=&#8221;objc&#8221;]<br \/>\nUIDevice* currentDevice = [UIDevice currentDevice];<br \/>\nif(currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) \u00a0{<br \/>\n    NSLog(@&quot;oh its iPad&quot;);<br \/>\n}else{<br \/>\n    NSLog(@&quot;This is iPhone&quot;);<br \/>\n}<br \/>\n[\/sourcecode]<\/p>\n<p><strong>3. Current iOS version<\/strong><\/p>\n<p>[sourcecode language=&#8221;objc&#8221;]<br \/>\nUIDevice* currentDevice = [UIDevice currentDevice];<br \/>\nfloat systemVersion = [currentDevice.systemVersion floatValue];<br \/>\n[\/sourcecode]<\/p>\n<p>This float value will tell you the current iOS version of device.<\/p>\n<p><strong>4. Current Orientation<\/strong><\/p>\n<p>It is common to have different layout for single application in portrait and\/or landscape view. In case of iPad it become more significant; Following method will tell you the current orientation of user&#8217;s device:<\/p>\n<p>[sourcecode language=&#8221;objc&#8221;]<br \/>\n-(int) currentLayout{<br \/>\nif (([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait || [[UIApplication sharedApplication] statusBarOrientation] == UIDeviceOrientationPortraitUpsideDown)) {<br \/>\n    \/\/ do something for portrait view;<br \/>\n} else {<br \/>\n     \/\/ do something for landscape view;<br \/>\n}<br \/>\n[\/sourcecode]<\/p>\n<p>Thats all.<br \/>\nShare Every bit of knowledge you have.<br \/>\nHappy Development;<\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/s08.flagcounter.com\/count\/J0P\/bg=FFFFFF\/txt=000000\/border=FFFFFF\/columns=6\/maxflags=200\/viewers=0\/labels=1\/pageviews=1\/\" alt=\"free counters\" border=\"0\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello Everyone;\u00a0 Hope weekend is going well. Today&#8217;s menu is really simple; I will give you some tips regarding iPhone application development. I used them recently, so want to share with you people. Here they are. 1. Screen Resolution At the time of this post, the iPhones are available in&#8230;<\/p>\n","protected":false},"author":1,"featured_media":5177,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[496,497,498,499,500,910],"class_list":["post-1772","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ios","tag-how-to-find-current-orientation-of-ipad","tag-how-to-find-current-version-of-ios","tag-how-to-find-device-type-in-xcode","tag-how-to-find-screen-dimensions-of-iphone","tag-how-to-find-screen-size-of-iphone","tag-screen-dimensions"],"_links":{"self":[{"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/posts\/1772","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/comments?post=1772"}],"version-history":[{"count":3,"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/posts\/1772\/revisions"}],"predecessor-version":[{"id":5178,"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/posts\/1772\/revisions\/5178"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/media\/5177"}],"wp:attachment":[{"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/media?parent=1772"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/categories?post=1772"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/tags?post=1772"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}