我的 cellForRowAtIndexPath 中有以下代码:
cell.appImageLogo.layer.cornerRadius = 10.0;
cell.appImageLogo.layer.masksToBounds = YES;
cell.appImageLogo.layer.borderColor = [UIColor clearColor].CGColor;
cell.appImageLogo.layer.borderWidth = 2.0;
我的问题是:它会导致内存问题吗?如果是,如何释放它消耗的内存?任何帮助将不胜感激。
最佳答案
如果你的cell没有被重用并且cell数量不多,或者你的cell被重用,则不会导致内存问题。
如果您的单元格被重复使用,并且如果cornerRadius
和borderColor
等属性相同,您可以在单元格为时的语句中编写代码无
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"YOURSTRING";
YourCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell==nil){
cell = [[YourCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
cell.appImageLogo.layer.cornerRadius = 10.0;
cell.appImageLogo.layer.masksToBounds = YES;
cell.appImageLogo.layer.borderColor = [UIColor clearColor].CGColor;
cell.appImageLogo.layer.borderWidth = 2.0;
}
// other different settings for different cells
return cell;
}
关于iphone - 设置对象的图层会导致内存问题吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15129112/