【发布时间】:2012-02-10 07:45:36
【问题描述】:
我的应用程序中有 UITableView 并且在创建任何类文件时通常创建了 tableview 单元格。 在我的表格单元格中,我添加了 UITextview,因为我的 UITableView 是“not scrolling smoothing”。 在我注释 textview 代码或将 textview 替换为 textfield/Label 之后,tableview 会尽可能顺畅地滚动。
谁能告诉我为什么会这样? 提前致谢。
这是我在表格中添加 textview 的方式:
UITextView *txtview = [[UITextView alloc]
initWithFrame:CGRectMake(93.0,36.0,190.0,94.0)];
txtview.backgroundColor = [UIColor clearColor];
txtview.text = [NSString stringWithFormat:@"%@",strText];
txtview.contentInset = UIEdgeInsetsMake(5 ,0 ,0 ,0);
txtview.textColor = [UIColor colorWithRed:221.0/255.0 green:249.0/255.0
blue:250.0/255.0 alpha:1.0];
[cell.contentView addSubview:txtview];
[txtview release];
这是我的细胞生成代码:
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell)
cell =[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1
reuseIdentifier:CellIdentifier]autorelease];
else
{
NSArray *arraySubviews = [cell.contentView subviews];
for (UIView *views in arraySubviews)
{
[views removeFromSuperview];
}
}
【问题讨论】:
-
你使用单元格复用吗?在此处粘贴单元生成代码。
-
@NeverBe :已经发布了我的细胞生成代码....
-
@vishy:txtShout 是我的错误...更新了我的代码...
标签: objective-c ios uitableview uitextview