![](/img/trans.png)
[英]UITableView WillDisplayCell Method call after particular time?
[英]Accessing -willDisplayCell method of moreNavigationController's UITableView
在moreNavigationController中設置UITableView
的backgroundView后,像這樣...
UITableView *moreTableView = (UITableView *)tabBarController.moreNavigationController.topViewController.view;
[moreTableView setBackgroundView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg.png"]]];
...該UITableView
的單元格將backgroundColor
從白色更改為透明(透明)。 我嘗試使用以下代碼行將其設置為白色...
for (UITableViewCell *cell in [moreTableView visibleCells]) {
[cell setBackgroundColor:[UIColor whiteColor]];
}
...但是不幸的是,這不起作用,所以我猜唯一的解決方案是在-willDisplayCell:
方法中設置backgroundColor。 誰能告訴我如何使用該方法? 任何幫助將不勝感激。
如果您有一個自定義單元格,則可以在UITabeViewCell
的子類中設置該單元格的背景色,否則應嘗試將此邏輯添加到UITableView數據源的tableView:cellForRowAtIndexPath:
方法。
您在循環中所做的操作只會影響可見的單元格,因為它們將被重用,並且如果將背景設置為動態清除,那么您將始終覆蓋背景。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.