【发布时间】:2013-02-17 14:29:26
【问题描述】:
我有一个基本的UITableView,我在网上填写了一个网络服务,但是我找不到根据我的textView 的高度来设置我的单元格高度(动态单元格数)的方法.
这是我填充单元格的方式:
UITextView *textView = (UITextView *)[cell viewWithTag:106];
textView.text = [[stories objectAtIndex:indexPath.row] objectForKey:@"texte"];
在我的cellForRow 方法中:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
我试过了,但得到了EXC_BAD_ACCESS的错误
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PerleCell"];
UITextView *textView = (UITextView *)[cell viewWithTag:106];
textView.text = [[stories objectAtIndex:indexPath.row] objectForKey:@"texte"];
CGFloat *heightCell = (CGFloat*)textView.text.length;
return *heightCell;
}
【问题讨论】:
-
您好,亲爱的,看看我的代码,如果您遇到任何问题,请回复我。记住在创建从不双端单元格时。始终创建新单元格并根据需要修改该单元格,然后添加返回该单元格。
-
不使单元格出列是不好的建议,并且会使您的应用程序使用更多的内存。
标签: iphone ios objective-c uitableview