我有一個靜態表格和3個單元格。我隨機在每個單元中放置一些標籤和其他控制器並運行它。它顯示很好。但是,當我放置一張圖像時,它一次只能覆蓋兩個或三個單元格。在UITableViewController
我評論所有tableView
方法。爲什麼發生這種情況?UIImage沒有正確定位在靜態單元格中
0
A
回答
1
- 這聽起來像你正在使用靜態單元格與
UITableViewDelegate
方法從你的描述,這不加起來。您不需要爲靜態表視圖實現這些方法。 - 檢查您的細胞高度以及是否啓用了
clipsToBounds
。 - 檢查您的
UIImageView
大小以及是否啓用了clipsToBounds
。
+0
感謝評論。我得到了解決方案。:) – Tulon 2015-02-08 08:53:06
0
我一直在尋找的是這樣的:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath];
if ((indexPath.row)==0)
{
cell.accessoryType = UITableViewCellAccessoryNone;
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"one"];
UIImageView *backgroundView =[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 170)];
backgroundView.image=[UIImage imageNamed:@"default-cover-image.jpg"];
[cell.contentView addSubview:backgroundView];
}
if ((indexPath.row)==1)
{
cell.accessoryType = UITableViewCellAccessoryNone;
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"two"];
UIImageView *backgroundView =[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
backgroundView.image=[UIImage imageNamed:@"sectionHeader.png"];
[cell.contentView addSubview:backgroundView];
}
if ((indexPath.row)==2)
{
cell.accessoryType = UITableViewCellAccessoryNone;
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"three"];
UIImageView *backgroundView =[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
backgroundView.image=[UIImage imageNamed:@"sectionHeader2.png"];
[cell.contentView addSubview:backgroundView];
}
if ((indexPath.row)==3)
{
cell.accessoryType = UITableViewCellAccessoryNone;
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"four"];
UIImageView *backgroundView =[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 170)];
backgroundView.image=[UIImage imageNamed:@"default-cover-image.jpg"];
[cell.contentView addSubview:backgroundView];
}
return cell;
}
如果我只是剛落靜態表格單元格內的imageView
,並在其中添加圖片,然後定位不準確的行動。雖然差異只出現在真實的設備上。不在故事板上。 感謝每一位評論我的帖子。祝你有美好的一天。 :)
相關問題
- 1. Openpyxl沒有正確寫入單元格
- 2. 表格單元格沒有在Chrome中正確包裝文字
- 3. Swift:創建靜態自定義單元格沒有dequeueReusableCellWithIdentifier
- 4. 在C中沒有正確設定靜態變量值#
- 5. GridBagLayout沒有正確定位
- 6. 確定DataGridView中的單元格位置
- 7. Abs。內部按鈕定位的元素沒有正確定位
- 8. Segue沒有在Swift中發送正確的單元格信息
- 9. 如何在tableview中創建動態單元格(沒有自定義單元格)?
- 10. UITableView與兩個自定義單元格沒有正確顯示
- 11. 動態表單元格未正確確定IE/Edge
- 12. ImagePickerController沒有正確定位在視圖
- 13. 在自定義靜態單元格內按UIButton時沒有采取行動
- 14. 有條件地顯示靜態單元格表格中的單元格
- 15. HTML表格單元格沒有正確對齊
- 16. 表格單元格沒有正確地跨越
- 17. uiimage沒有正確放入子視圖
- 18. XCode storyboard中的自定義靜態表格單元格?
- 19. 單元格寬度在靜態UITableView
- 20. 在靜態單元格上使用UIDatePicker
- 21. Cocoa中的靜態NSTableView單元格
- 22. 在靜態行中創建自定義單元格UITableView
- 23. Segue從靜態單元格動態TableViewController
- 24. 在Xcode中動態調整UITableView單元格內的UIImage寬度
- 25. 靜態表格視圖單元格標籤正陷入頁眉
- 26. 在Excel中確定單元格中的#
- 27. UINavigationController導航欄沒有正確定位
- 28. android:layout_alignParentBottom,android:layout_alignParentRight沒有正確定位
- 29. 嵌套的DIV沒有正確定位
- 30. 劃分框沒有正確定位
「當我把圖像」 - 但你怎麼做?很明顯,你這樣做的方式是錯誤的。但是你不是在展示你在做什麼,那麼人們怎麼能夠「理解」它呢? – matt 2015-02-07 19:14:00
Pease分享一些代碼,所以我們可以幫助你。如果您使用故事板或XIB設計您的單元格,請張貼它的一些截圖。 – Romain 2015-02-07 19:15:20
拖放。沒有代碼。沒有CGRect。我現在不是正確的方式嗎? : -/ – Tulon 2015-02-07 19:28:59