表视图在初始加载时不会动态更改

时间:2013-11-14 17:15:30

标签: ios uitableview custom-cell

我正在尝试创建一个具有独特样式的表,以便我的标签大小随内容动态变化。我能够让单元格在它出列一次之后改变样式(即一旦我向下滚动到一个新页面,那些单元格被格式化然后当我向后滚动单元格被格式化时)但似乎无法做到这一点初始负荷。标签仅限于该方法,因为只要我尝试使它们更可用,它就会导致故事板失败。

static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];


NSDictionary *pastVerse = [self.pastVerses objectAtIndex:indexPath.row];

UILabel *label;

label = (UILabel *)[cell viewWithTag:1];
label.text = [pastVerse valueForKey:@"reference"];

label = (UILabel *)[cell viewWithTag:2];
label.text = [pastVerse valueForKey:@"version"];

label = (UILabel *)[cell viewWithTag:3];
label.text = [pastVerse valueForKey:@"verse"];

[label setNumberOfLines:0];
[label sizeToFit];

0 个答案:

没有答案