2016-03-29 75 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,或搜索控制檯輸出以查找約束衝突。如果是這樣,您需要調整約束條件並刪除其中一個底部約束條件。

相關問題