问题
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