vai*_*hav 1 memory-management objective-c uitableview
我不确定使用或不使用内部方法的tableView内存分配过程。reuseIdentifier statictableView delegate
假设我们有 20 个从方法 method 返回的数组,那么每次调用方法时,在方法之后将在内存中分配numberOfRowsInSection多少个数组。cellcellForRowAtIndexPath[UITableViewCell alloc] alloc
示例代码:
(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
}
Run Code Online (Sandbox Code Playgroud)
任何有用的澄清将不胜感激,感谢您的宝贵时间。
| 归档时间: |
|
| 查看次数: |
1463 次 |
| 最近记录: |