{"id":5368,"date":"2014-03-30T21:07:47","date_gmt":"2014-03-30T21:07:47","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/ios-5-create-a-custom-view-collection-of-common-programming-errors\/"},"modified":"2014-03-30T21:07:47","modified_gmt":"2014-03-30T21:07:47","slug":"ios-5-create-a-custom-view-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/ios-5-create-a-custom-view-collection-of-common-programming-errors\/","title":{"rendered":"iOS 5 Create a custom view-Collection of common programming errors"},"content":{"rendered":"<p>At the top level it looks like they have a <code>UIToolbar<\/code> and a <code>UITableView<\/code> or a <code>UIScrollView<\/code>. They have used some custom graphics in the toolbar; possibly they have implemented their own toolbar class.<\/p>\n<p>The table view is probably using a custom <code>UITableViewCell<\/code> subclass. It is using variable height rows (by defining the <code>tableView:heightForRowAtIndexPath:<\/code> method in the delegate). They might just be using a scroll view instead of a table view, but I&#8217;ll assume it&#8217;s a scroll view for this discussion.<\/p>\n<p>Each cell has appears to have at least three subviews: one to draw the cell&#8217;s title bar, one to draw the cell&#8217;s contents, and a <code>UIPageControl<\/code> to draw the page dots under the contents.<\/p>\n<p>The contents part of the cell looks like it&#8217;s probably a scroll view, with some subviews to draw images (<code>UIImageView<\/code>) and labels (<code>UILabel<\/code>). The subviews of the scroll view are quite different for the different table view cells.<\/p>\n<p>You could lay out an interface like this using nibs. I&#8217;d probably use four nibs: one for the top-level with the toolbar and the table view, one nib for the table view cell, one nib for the gift layout (which has a <code>UILabel<\/code> over a <code>UIImageView<\/code>), and one nib for the person\/date layout (which has a <code>UIImageView<\/code> to the left of three <code>UILabel<\/code>s).<\/p>\n<p>You need to set some properties in code. For example, suppose you have one nib for the overall layout of a table view cell. It probably has a view hierarchy like this:<\/p>\n<pre><code>UITableViewCell (or subclass)\n    UIView to provide the colored stripe across the top\n        UIImageView for the icon\n        UILabel for the title (\"Browse Gifts\", \"Birthdays\", etc.)\n        UIButton for the disclosure indicator\n    UIView to provide the white background with shadow\n        UIScrollView to hold the main content of the cell\n        UIPageControl\n<\/code><\/pre>\n<p>When you load this nib to use for your &#8220;Browse Gifts&#8221; cell, you need to set the shadow properties of the white background view&#8217;s layer, because you can&#8217;t do that in the nib. You need to set the color of the stripe, the icon, and the title text of the cell on the appropriate views. You need to add content to the scroll view (which probably involves loading another nib once for each content item). You need to set the number of pages on the page control.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>At the top level it looks like they have a UIToolbar and a UITableView or a UIScrollView. They have used some custom graphics in the toolbar; possibly they have implemented their own toolbar class. The table view is probably using a custom UITableViewCell subclass. It is using variable height rows (by defining the tableView:heightForRowAtIndexPath: method [&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-5368","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5368","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=5368"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5368\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5368"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5368"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}