{"id":5023,"date":"2014-03-30T17:59:47","date_gmt":"2014-03-30T17:59:47","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/objective-chow-to-define-cell_content_width-for-both-iphone-and-ipad-collection-of-common-programming-errors\/"},"modified":"2014-03-30T17:59:47","modified_gmt":"2014-03-30T17:59:47","slug":"objective-chow-to-define-cell_content_width-for-both-iphone-and-ipad-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/objective-chow-to-define-cell_content_width-for-both-iphone-and-ipad-collection-of-common-programming-errors\/","title":{"rendered":"Objective-C:How to define CELL_CONTENT_WIDTH for both iPhone and iPad?-Collection of common programming errors"},"content":{"rendered":"<p>If you have a universal app, then you differentiate between the iPad and the iPhone at build time. So you can&#8217;t make <code>#define<\/code>s with different values for the two devices.<\/p>\n<p>However you can determine the type of the device at runtime using <code>UI_USER_INTERFACE_IDIOM()<\/code>:<\/p>\n<pre><code>if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {\n    \/\/ iPhone\n    \/\/ ...\n} else {\n    \/\/ iPad\n    \/\/ ...\n}\n<\/code><\/pre>\n<p>320 is also the width of the iPhone screen. So if you want your cells to have the width of the device screen, you can determine that like this:<\/p>\n<pre><code>CGFloat width = [UIScreen mainScreen].bounds.size.width;\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>If you have a universal app, then you differentiate between the iPad and the iPhone at build time. So you can&#8217;t make #defines with different values for the two devices. However you can determine the type of the device at runtime using UI_USER_INTERFACE_IDIOM(): if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { \/\/ iPhone \/\/ &#8230; } else { \/\/ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5023","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5023","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5023"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5023\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5023"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5023"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5023"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}