ios之清除cell缓存,解决cell的重用问题。

tableView表格中的cell有重用机制,这是一个很好的东西,可以避免开辟很多的空间内存。但是有时候我们不想让它重用cell,,可以用以下的代码解决。

将这个代码放在:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ }这个函数中执行就好了。

 

  1. //清楚cell的缓存  
  2. NSArray *subviews = [[NSArray alloc] initWithArray:cell.contentView.subviews];  
  3. for (UIView *subview in subviews) {  
  4.     [subview removeFromSuperview];  
  5. }  
posted @ 2013-10-28 15:33  苹果吧  阅读(4204)  评论(0编辑  收藏  举报