【发布时间】:2016-09-09 07:26:26
【问题描述】:
我不确定使用reuseIdentifier static 或不在tableView delegate 方法内的tableView 内存分配过程。
假设如果我们有 20 个从方法 numberOfRowsInSection 方法返回的数组,那么通过一次调用 [UITableViewCell alloc] alloc 方法,在 cellForRowAtIndexPath 方法之后将在内存中分配多少 cell。
示例代码:
(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 20; // array count
}
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil){ cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:MyIdentifier];
// how many cell will be alloc here
}
// configure cell
}
感谢您抽出宝贵时间提供任何有用的说明。
【问题讨论】:
-
行的
Height是什么? -
@pkc456
height由default提供,感谢您的宝贵时间.. -
我尝试将此添加为评论,但它太长了。所以请检查我的answer。
标签: objective-c uitableview memory-management