Sealyu

          --- 博客已遷移至: http://www.sealyu.com/blog

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            618 隨筆 :: 87 文章 :: 225 評論 :: 0 Trackbacks

          Beautiful Table View Helper Class

          Beautiful Table View Demo Screenshot

          Beautiful Table View Demo Screenshot

          A while back, Matt Gallagher from Cocoa with Love wrote an excellent post on customizing UITableView drawing.

          In the article, Matt shows how you can style UITableViews quite easily by setting the backgroundView and selectedBackgroundView to UIImageViews containing custom background images for each cell. The only trick to it is to make sure that you choose the proper image based on whether you’re the top row, bottom row, middle row, or only row in the table.

          Anyway, I’ve found the techniques he mentions in the article pretty useful in a number of projects, so I wrote Beautiful Table View helper class so I could get the functionality easily whenever I want to include a table view controller. I thought I’d post the code here in case anyone else might find it useful: here’s a sample project.

          To “beautify” your table view controller, all you have to do is derive your view controller from BeautifulTableViewController like so:

          @interface FavoriteGamesTable : BeautifulTableViewController {
                      // Your implementation
                      }

          Then implement numberOfSectionsInTableView, numberOfRowsInSection, and cellForRowAtIndexPath like you normally would. The only other thing you have to do is insert the following line before you return from cellForRowAtIndexPath:

          [super beautifyCell:cell atIndexPath:indexPath];

          And make sure to call [super viewDidLoad] in your viewDidLoad method. And that’s it! So feel free to use the Beautiful Table View Helper (and even the art, drawn by my talented wife!) in your projects if you find it useful. And thanks again to Matt for letting me know about this method!

          posted on 2010-10-01 21:30 seal 閱讀(203) 評論(0)  編輯  收藏 所屬分類: iPhone
          主站蜘蛛池模板: 吐鲁番市| 彭山县| 怀仁县| 沽源县| 祁阳县| 孙吴县| 济宁市| 武威市| 樟树市| 鲁山县| 香港 | 凤阳县| 唐河县| 青海省| 泗阳县| 南丹县| 仲巴县| 静宁县| 黄陵县| 合川市| 山丹县| 南岸区| 沾益县| 金阳县| 芦溪县| 靖宇县| 汉中市| 峨眉山市| 海林市| 岫岩| 建阳市| 子洲县| 蚌埠市| 麻阳| 青阳县| 梁山县| 罗甸县| 漠河县| 苍山县| 江门市| 长葛市|