作者Gsus (肉元,吉米,助教)
看板MacDev
标题[问题] 有关customed table cell 的 作法
时间Wed Jul 14 22:44:43 2010
我今天看到一个小短片在教学如何用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