滚动时自定义UITableViewCell内容不移动

时间:2013-08-07 18:59:33

标签: iphone ios objective-c uitableview uilabel

我有一个UITableView,其中包含使用Storyboard的自定义单元格。自定义单元格中的所有对象都可以工作,但当我在UITableView中滚动时,对象不会移动:

enter image description here

这是我的代码:

- (UITableViewCell *)tableView:(UITableView *)tableview cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"MainCell";

MainCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[MainCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.subtitle.text = [NSString stringWithFormat:@"%@",theEvent.startDate];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}

enter image description here

关于我做错了什么的任何想法?感谢。

1 个答案:

答案 0 :(得分:0)

我弄明白了这个问题。我放在UITableViewCell上的对象实际上并不在单元格内,而是在UITableView之上,因此它们充当“浮动”对象。

相关问题