[問題] 有關customed table cell 的 作法
我今天看到一個小短片在教學如何用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
討論串 (同標題文章)
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章