2016-03-29 79 views
0

我确实试图让这件事情起作用。我读了很多文章,但没有一篇给出了适当的解决方案。我想从xcode中获得的所有内容都是让我通过编程方式更改单元格中imageview的顶部约束。我已经为ipad全屏设置了我的限制,但我想调整ipad Pro的几个限制。以编程方式更改单元格中的图像视图的约束条件

首先我想这:

- (void)updateConstraints 
{ 
    [super updateConstraints]; 
    self.imageViewTopConstraint.constant = 300.f; 
} 
- (void)awakeFromNib { 
// // Initialization code 
    [self setNeedsUpdateConstraints]; 
} 

,并没有工作。

然后我试图把此行

self.imageViewTopConstraint.constant = 300.f; 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 

仍然没有工作。我调整了细胞高度,但它也没有工作。

你可以请我帮帮忙吗?

P.S:xcode的新手。

百万在此先感谢。 This is the custom cell i have created.

Breakpoint

Here is the storyboard.

+0

如何定义'imageViewTopConstraint'? –

+0

你有没有试过[cell updateConstraintIfNeeded];改变约束后的常量值。 –

+0

@InderKumarRathore我已将nslayoutconstraint的iboutlet连接到自定义单元类 –

回答

1

有你的ImageView底部约束设置为电池的底部或标签链接到单元格的底部?你是否收到约束冲突异常?您可以使用符号添加符号断点:UIViewAlertForUnsatisfiableConstraints,或搜索控制台输出以查找约束冲突。如果是这样,您需要调整约束条件并删除其中一个底部约束条件。

相关问题