xcode文档大纲有额外的内容视图

时间:2014-07-20 05:03:06

标签: ios objective-c xcode

我正在学习目标c,我在这里遵循本教程:

http://www.raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1

每当我创建一个表格单元格视图时,它会创建一个额外的内容视图,使得无法将我的标签,图像链接到单元格。如何删除额外的内容视图并链接我的对象?

这是截图,显示我的意思......

enter image description here

使用此代码获取错误...在单元格上使用未声明的标识符。

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

MingleViewCell *cell = (MingleViewCell *)[[tableView dequeueReusableCellWithIdentifier:@"MingleViewCell"]];
LocalPerson *local = [self.people objectAtIndex:indexPath.row];
cell.nameLabel.text = local.name;
cell.aboutMeLabel.text = local.game;
return cell;
 }

2 个答案:

答案 0 :(得分:1)

放松。来自the docsThe content view of a UITableViewCell object is the default superview for content displayed by the cell. If you want to customize cells by simply adding additional views, you should add them to the content view so they will be positioned appropriately as the cell transitions into and out of editing mode.

这就是它的完成方式,内容视图应该在那里,您应该能够通过从添加到故事板中的单元格的元素中拖放到自定义单元格类代码中来正常连接IBOutlets / IBActions

答案 1 :(得分:0)

你不应该删除你所呼叫的内容视图是额外的。如果您看到UITableViewCell默认情况下具有属性contentView,您可以在其中添加所有其他内容,如UIButton,UILabel等。这是contentView,它是主容器。

因此,无论何时从UITableViewCell继承任何类,该类也都具有此contentView。因此,您可以将其用作容器并添加其他元素,而不是删除它。