如何以编程方式添加约束到TableView单元格的默认文本标签和配件



我有一个单元格,并且由于我想要默认行为,所以我正在使用以下方式 -

returnCell.textLabel.text = @"Some long text Some long text";
returnCell.textLabel.lineBreakMode = NSLineBreakByWordWrapping;
returnCell.textLabel.numberOfLines = 0;
UISwitch *toggleSwitch = [[UISwitch alloc] initWithFrame:CGRectZero];
returnCell.accessoryView = toggleSwitch;
[returnCell.contentView setTranslatesAutoresizingMaskIntoConstraints:NO];
[returnCell.textLabel setTranslatesAutoresizingMaskIntoConstraints:NO];
[returnCell addVisualConstraints:@"H:|[contentView]|"
                            forViews:@{@"contentView":returnCell.contentView}];
[returnCell addVisualConstraints:@"V:|[contentView]|"
                            forViews:@{@"contentView":returnCell.contentView}];

现在我遇到的问题是,如果小工作正常,则文本很长,但是它会在开关后面。

现在我的问题是如何避免这种情况并添加约束以在我的textlabel和cockestoryView(uiswitch)之间解决此问题,这两个都陷入困境,并且没有添加为单元格的ContentView?

的子视图。

预先感谢!!!请帮忙。

第一个项目直到远离开关(辅助视图)

最新更新