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

查看:23
本文介绍了在 Storyboard 中创建自定义 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.

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

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