带有左右标签的UITableViewCell的最佳方法 [英] Best approach for UITableViewCell with both a left and right label

查看:162
本文介绍了带有左右标签的UITableViewCell的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用具有多项选择的设置(例如,枚举值).我想复制iOS的声音设置表视图单元格,其中名称在左侧,所选值在右侧,然后是显示指示器(>).

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 (>).

到目前为止,我的方法是创建一个自定义表格视图单元格(.xib和自定义UITableViewCell类),并在该单元格的内容视图中添加一个值标签.但是,似乎使用textLabel与自定义内容视图不兼容(请参阅我的其他问题以及此答案).我的猜测是分配textLabel?.text会导致内容视图被覆盖或隐藏.

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?

推荐答案

您不需要自定义单元格.使用普通的旧UITableViewCell,但将样式设置为UITableViewCellStyleValue1-Objective-C或Value1-Swift.

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

左边的标签是textLabel,右边的标签是detailTextLabel.

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

这篇关于带有左右标签的UITableViewCell的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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