UITableView UITableViewCellStyle.Value1 TextLabel 与 DetailTextLabel 重叠

UITableView UITableViewCellStyle.Value1 TextLabel is overlapping the DetailTextLabel

我正在使用 Xamarin iOS,在 iOS 9.2 设备上,单元格样式为 UITableViewCellStyle.Value1 的 UITableView 单元格具有与 DetailTextLabel 重叠的 TextLabel。

这不会发生在 iOS 8. 任何人都知道我可以做些什么来修复它而无需滚动我自己的单元格?我只想将 TextLabel 省略而不是与 DetailTextLabel 重叠。

我找不到修复程序。一个空白项目只用一个简单的 TableView 复制了它,所以我滚动了我自己的自定义单元格。

public class CustomTableViewCell : UITableViewCell
{
        UILabel headingLabel, subheadingLabel;

        public MTableViewCell (NSString cellId) : base (UITableViewCellStyle.Default, cellId)
        {
            SelectionStyle = UITableViewCellSelectionStyle.Default;
            headingLabel = new UILabel ();
            subheadingLabel = new UILabel () {
                TextColor = UIColor.Gray,
                TextAlignment = UITextAlignment.Center
            };
            ContentView.AddSubviews (new UIView[] { headingLabel, subheadingLabel });
        }

        public override void LayoutSubviews ()
        {
            base.LayoutSubviews ();
            headingLabel.Frame = new CGRect (15, 0, ContentView.Bounds.Width - 130, ContentView.Bounds.Height);
            subheadingLabel.Frame = new CGRect (ContentView.Bounds.Width - 110, 0, 95, ContentView.Bounds.Height);
        }

        public override UILabel TextLabel {
            get {
                return headingLabel;
            }
        }

        public override UILabel DetailTextLabel {
            get {
                return subheadingLabel;
            }
        }
}

决定是否要将 value1 或子类型的单元格出列的 Pasudocode

public static func isVerticalLayout(primary: String, secondary: NSAttributedString,
                                    liveHostView: UIView) -> Bool
{
    let csWidth = liveHostView.bounds.width

    let headingLabel = UILabel()
    let subheadingLabel = UILabel()
    headingLabel.text = primary
    headingLabel.numberOfLines = 0
    headingLabel.lineBreakMode = .byWordWrapping
    subheadingLabel.attributedText = secondary
    subheadingLabel.textAlignment = .right
    subheadingLabel.numberOfLines = 1
    subheadingLabel.lineBreakMode = .byWordWrapping

    let clipw =  csWidth - P97GEL.Constants.leftTextMargin - P97GEL.Constants.rightTextMargin
    let bounds = CGRect(x: 0, y: 0, width: clipw, height: CGFloat.greatestFiniteMagnitude)
    let psRect = headingLabel.textRect(forBounds: bounds, limitedToNumberOfLines: 1)
    let ps = psRect.size
    let ssRect = subheadingLabel.textRect(forBounds: bounds, limitedToNumberOfLines: 1)
    let ss = ssRect.size

    headingLabel.frame.origin = CGPoint(x: P97GEL.Constants.leftTextMargin, y: P97GEL.Constants.verticalMargin)
    headingLabel.frame.size = ps
    subheadingLabel.frame.size = ss

    if csWidth >= ps.width + ss.width + (3 * P97GEL.Constants.horizontalMargin) {
        return false
    } else {
        return true
    }
}