問題描述
想要創建一個靜態菜單 (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的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!