我有UITableView
大量数据。我UITableViewCell
每次都像这样创建:
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:strCellIdentifier];
之后,我将许多UIView
作为子视图添加到UITableViewCell
例如
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button addTarget:self action:@selector(onDocumentLogoTapped:) forControlEvents:UIControlEventTouchUpInside];
button.frame = imageRect;
button.tag = indexPath.row;
[cell addSubview:button];
就像这样,我还添加了UIImageView
. 问题是由于内存问题,我UITableView
变得非常慢并且应用程序有时会崩溃。
任何人都可以建议我UITableViewCell
在添加 subView 时使用正确的方法吗?