How do you create a custom prototype cell with master detail view in Xcode?

ぐ巨炮叔叔 提交于 2019-12-03 20:29:50

That's standard practice. Just ignore the built in textLabel and be done with it. By default the label is blank anyway. It's set in code.

To access new labels and such, create a new custom class for the custom cell (File|New|File...|Objective-C Class in XCode), give it a name and for the subclass choose UITableViewCell. Finally, on the Identity Inspector for the custom cell in Interface Builder, choose that new class for the Custom Class.

Now, from the Assistant Editor in XCode, you can CTRL-drag new labels and such to the .h file of the new custom cell class to create IBOutlet properties.

Be sure to set the cell Identifier on the Attributes Inspector tab for the cell and reference that in your code, especially in cellForRowAtIndexPath.

Import the custom cell class's .h file in the view controller's .h file, then cast the cell to your custom cell class in cellForRowAtIndexPath to access the new properties or change the definition UITableViewCell *cell = to your new class like MyTableViewCell *cell =.

By default, the Style of the table cell is "Basic" in Master-Detail projects. Select the Table View Cell and open the Attributes Inspector. Change the Style from Basic to Custom.

Doing this removes the default label and allows you to add new controls.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!