在故事板中创建自定义UITableViewCell [英] Creating custom UITableViewCell's within a Storyboard

查看:92
本文介绍了在故事板中创建自定义UITableViewCell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想要创建静态菜单(IOS 5)并尝试在故事板中创建自定义单元格,然后加载到分组的tableview上。

Wanting to create a static menu (IOS 5) and attempting to create custom cells within the storyboard to then load onto the grouped tableview.

我创建了

@property(nonatomic,strong) IBOutlet UITableViewCell *labelCell;

ViewController类设置为正确的TableViewController,我已将自定义单元格连接到此插座。

The ViewController class is set to the proper TableViewController and I've connected the custom cell to this outlet.

我也设置了委托和数据源。

I also have the delegate and datasource set up.

我有

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath   *)indexPath
{
  return self.labelCell;
}

我确定这有一个错误,但我是只是试图显示一个单元格并从那里开始。似乎没有任何通过故事板在IB中进行自定义单元格的示例。我仍然可以使用旧方法创建一个xib文件并将其加载到mainBundle中,但我只是想保持最新状态。

I'm sure there is a ton wrong with this, but I'm just trying to display one cell and go from there. There does not seem to be any examples of doing custom cells within the IB through the storyboard. I can still use the old way of creating a xib file and loading it in the mainBundle but I just want to stay up to date I guess.

但是我上面的内容让我在加载这个视图控制器时崩溃了。 SIGABRT

but with what I have above i get a crash when I load this view controller. SIGABRT

推荐答案

如果您已将 UITableView 设置为使用'静态故事板中的单元格,您不需要实现任何 UITableViewDataSource 方法,您可以直接在Interface Builder中修改单元格。对于单个标签单元格,选择单元格并将其类型更改为基本。您现在可以像编辑任何其他视图对象一样编辑单元格。

If you have set your UITableView to be using 'Static Cells' in the storyboard, you don't need to implement any of the UITableViewDataSource methods and you can modify the cell directly in Interface Builder. For a single label cell, select the cell and change it's type to 'Basic'. You can now edit the cell just like you would any other view object.

这篇关于在故事板中创建自定义UITableViewCell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆