[問題] 有關customed table cell 的 作法

看板MacDev作者 (肉元,吉米,助教)時間15年前 (2010/07/14 22:44), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/5 (看更多)
我今天看到一個小短片在教學如何用interface builder製作customed tableview cell 在一個ProductsViewController.m 中 override tableview datasource: - (UITabeViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: 中的一段code是這樣的 static NSString *CellIdentifier = @"ProductCellId"; ProductTableCell *cell = (ProductTableCell *)[tableView dequeReusableCellWithIdentifier: CellIdentifier]; if (cell == nil) { [[NSBundle mainBundle] loadNibName:@"ProductTableCell" owner:self options:...] cell = self.productCell; } P.S. <ProductsViewController.h> #import <UIKit/UIKit.h> @class ProductTableCell; @interface ProductsViewController : UITableViewController { NSArray *products; IBOutlet ProductTableCell *productCell; } @property (nonatomic, retain) NSArray *products; @property (nonatomic, retain) ProductTableCell *productCell; @end 我的疑問是 1. 為什麼不是一般我們所想像的一直去建立ProductTableCell * 而是用他寫的這種load nib file的方式? 另外一問 2. 他這樣load nib file的方式來產生cell的運作原理是什麼呢? 謝謝囉~~ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 111.251.144.229
文章代碼(AID): #1CFSrT2S (MacDev)
文章代碼(AID): #1CFSrT2S (MacDev)