[請益] 詢問TableViewCell相關問題
請問如果要讓UITableViewCell可重複使用節省記憶體,但CellStyle又要是Subtitle應該
要怎麼寫呢?
問過朋友是說需要另外寫一個TableViewCell的Subclass,再override init去修改style
依照我自己找出來的方法執行後ViewCellStyle還是default,希望各位前輩能幫忙指點是
哪裡的問題 感激不盡 ><
以下是擷取TableView相關的code
===========
@interface CustomCell : UITableViewCell
@end
@implementation CustomCell
-(id)init
{
self = [super initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:@"cellID"];
return self;
}
@end
===========
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomCell* c = [[CustomCell alloc]init];
c = [tableView dequeueReusableCellWithIdentifier:@"cellID"];
return c;
}
===========
-(void) viewDidLoad
{
[self.tableView registerClass: [CustomCell class] forCellReuseIdentifier:
@"cellID"];
}
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.227.149.174
※ 文章網址: http://www.ptt.cc/bbs/MacDev/M.1398156851.A.CE7.html
→
04/22 17:49, , 1F
04/22 17:49, 1F
→
04/22 17:49, , 2F
04/22 17:49, 2F
→
04/22 17:50, , 3F
04/22 17:50, 3F
→
04/22 17:51, , 4F
04/22 17:51, 4F
→
04/22 17:51, , 5F
04/22 17:51, 5F
→
04/23 16:24, , 6F
04/23 16:24, 6F
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章