Ios 带UITextView块UI的UITableViewCell
我在一个单元格内有一个UITextView,当滚动时,UI会冻结一段很短但很明显的时间,等待创建单元格 有没有类似的文本视图体验?为什么创建这样一个单元需要时间?是否可以在后台线程上创建它以避免冻结Ios 带UITextView块UI的UITableViewCell,ios,uitableview,uitextview,tableviewcell,Ios,Uitableview,Uitextview,Tableviewcell,我在一个单元格内有一个UITextView,当滚动时,UI会冻结一段很短但很明显的时间,等待创建单元格 有没有类似的文本视图体验?为什么创建这样一个单元需要时间?是否可以在后台线程上创建它以避免冻结 - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:UITableViewCellStyle
- (id)initWithStyle:(UITableViewCellStyle)style
reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:reuseIdentifier];
if (!self) {
return nil;
}
[self setupTextView];
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.backgroundColor = [UIColor clearColor];
return self;
}
- (void)setupTextView
{
UITextView *textView = [[UITextView alloc] init];
textView.translatesAutoresizingMaskIntoConstraints = NO;
textView.layer.borderColor = [UIColor lightGrayColor].CGColor;
textView.layer.borderWidth = 0.4f;
textView.layer.cornerRadius = 4.0f;
textView.textColor = [UIColor lightGrayColor];
[self.contentView addSubview:textView];
[self.contentView addConstraint:[NSLayoutConstraint
constraintWithItem:textView
attribute:NSLayoutAttributeHeight
relatedBy:NSLayoutRelationEqual
toItem:self.contentView
attribute:NSLayoutAttributeHeight
multiplier:1.0
constant:-18.0]];
[self.contentView addConstraint:[NSLayoutConstraint
constraintWithItem:textView
attribute:NSLayoutAttributeWidth
relatedBy:NSLayoutRelationEqual
toItem:self.contentView
attribute:NSLayoutAttributeWidth
multiplier:1.0
constant:-18.0]];
[self.contentView addConstraint:[NSLayoutConstraint
constraintWithItem:textView
attribute:NSLayoutAttributeCenterY
relatedBy:NSLayoutRelationEqual
toItem:self.contentView
attribute:NSLayoutAttributeCenterY
multiplier:1.0
constant:0.0]];
[self.contentView addConstraint:[NSLayoutConstraint
constraintWithItem:textView
attribute:NSLayoutAttributeCenterX
relatedBy:NSLayoutRelationEqual
toItem:self.contentView
attribute:NSLayoutAttributeCenterX
multiplier:1.0
constant:0.0]];
_textView = textView;
}
你能粘贴你的cellforRowAtIndexPath代码吗?因此,我们可以帮助您更好地发布手机代码听起来您在手机重用方面犯了严重错误。滚动时通常不创建单元格,为什么不使用原型单元格?他们肯定会让你的生活更轻松一点,我使用的是经典模式:在视图中注册单元格,然后卸载,这样就不会有任何问题。你说的原型电池是什么意思?