Best approach for UITableViewCell with both a left and right label

房东的猫 提交于 2019-12-23 16:24:39

问题


My app has several settings that multiple choice (e.g. an enum value). I want to replicate iOS' sound settings table view cell, where the name is on the left, the selected value on the right, followed by a disclosure indicator (>).

My approach so far has been to create a custom table view cell (.xib and custom UITableViewCell class), with a value label added to the cell's content view. However, it appears that using textLabel is incompatible with a custom content view (see my other question as well as this answer). My guess is assigning textLabel?.text causes content view to be overridden or hidden.

What's the best approach for doing this?


回答1:


You don't need a custom cell. Use a plain old UITableViewCell but set the style to UITableViewCellStyleValue1 - Objective-C or Value1 - Swift.

The label on the left is the textLabel and the label on the right is the detailTextLabel.



来源:https://stackoverflow.com/questions/35686628/best-approach-for-uitableviewcell-with-both-a-left-and-right-label

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