Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在两个标签之间创建距离约束_Ios_Objective C_Autolayout - Fatal编程技术网

Ios 在两个标签之间创建距离约束

Ios 在两个标签之间创建距离约束,ios,objective-c,autolayout,Ios,Objective C,Autolayout,我正在uitableviewcell上渲染两个标签。我想增加他们之间的距离。 这是我的代码: - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { NSDictionary *values = self.viewModel.dataSet[indexPath.row]; NSString

我正在uitableviewcell上渲染两个标签。我想增加他们之间的距离。 这是我的代码:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
  NSDictionary *values  = self.viewModel.dataSet[indexPath.row];
  NSString *key         = values.allKeys.firstObject;
  id value              = values[key];
  [NSLayoutConstraint constraintWithItem: cell.textLabel attribute: NSLayoutAttributeBottom
                               relatedBy:NSLayoutRelationEqual toItem: cell.detailTextLabel
                               attribute: NSLayoutAttributeTop multiplier:1.0 constant:20.0];

  .....
然而,它们似乎没有移动


有人能帮我吗?我不太熟悉通过代码创建约束。

添加约束后,请尝试[cell LayoutifNeed],不要仅使用UITableViewCell创建带有自己标签的自定义子类,因为您将无法轻松或很好地更改UITableViewCell视图。