2014-10-29 76 views
2

我已經基於故事板和UITableView與UIViewTableViewCell(風格右詳細)的視圖之一的項目。UITableViewCell的寬度

enter image description here

在Xcode中一切正常,但是當我在模擬器或設備啓動應用程序,該表格單元格看起來太寬。

enter image description here

你有任何建議,這可能是這種奇怪的現象的原因嗎?我應該改變什麼才能讓細胞完全可見?

編輯:

我附加的cellForRowAtIndexPath:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
static NSString *CellIdentifier = @"MyTableCell"; 

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
} 

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 

return cell; 
} 
+0

它的工作原理與iPhone4一樣嗎? – 2014-10-29 08:52:29

+1

你可以從cellForRowAtIndexPath發佈代碼嗎? – ZeMoon 2014-10-29 09:05:17

+0

@ZeMoon我編輯了主要問題。 – Grzegorz 2014-10-29 09:23:04

回答

1

有你把相同的寬度爲您的自定義單元格,作爲一個UITableView的寬度是多少?

enter image description here

而且,你有你的管理「刪除」標籤尺寸正確(使用自動版式或自動尺寸)。 隨着新款iPhone 6的推出,我們不得不關注widtch,就像iPhone 5推出時的高度一樣。

我可以從這兩個截圖中看到,您發佈的是使用iPhone6大小的ViewController進行開發並在iPhone5上運行它。

我確定你沒有管理Autolayout/Autoresizing,因爲你應該。

嘗試這樣做,你的「刪除」的標籤:

enter image description here

+0

感謝您的建議。最初在我的問題,我把錯誤的第一個屏幕(現在更新)。我使用iPhone 4.7「在故事板中,我選中了」使用自動佈局「和」使用大小類別「。在我的示例中,我刪除了單元格中的所有自定義字段,並且僅設置了Xcode'右側詳細'任何自定義值。正如你所看到的'細節'在屏幕之外。 – Grzegorz 2014-10-29 09:48:12

0

我哪裏對我的tableView的右側的含量被切斷了同樣的問題。

原因是,我已經爲自定義tableViewCell中的視圖正確設置了Autolayout約束條件。但是,我沒有爲tableView本身設置AutoLayoutConstraints。因此UITableView沒有被正確地約束,在我的情況下太大了。