[英]tableView: didSelectRowAtIndexPath: looks awful if not setting the next viewcontroller's background color
[英]Setting moreViewController TableView background color
花了幾個小時試圖解決這個問題后,我想我已經盡了一切可能,我在這里尋求一些幫助:)
我在UITableView
有一個帶有3行的更多UINavigationController
,我可以設置三個單元格的背景,但是其他空單元格的顏色是不同的(我只是不知道該顏色在哪里顯示!)
我嘗試設置UITableView
背景顏色,但是無法做到這一點,它永遠不會改變:我錯了嗎? 因為我一定是錯的。
接下來是我編寫的代碼。
您將如何更改剩余的空白單元格或修復UITableView
背景色?
…
[[[tabBarController.viewControllers objectAtIndex:4]tabBarItem]setTitle:@"Settings"];
[[[tabBarController.viewControllers objectAtIndex:5]tabBarItem]setTitle:@"Hazards"];
[[[tabBarController.viewControllers objectAtIndex:6]tabBarItem]setTitle:@"Beaufort Scale"];
…
UIViewController *tabBarMore = [tabBarController.moreNavigationController.viewControllers objectAtIndex:0];
[tabBarMore.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:3.0/255.0 green:30.0/255.0 blue:100.0/255.0 alpha:1.0]];
NSDictionary *textAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor],NSForegroundColorAttributeName,
nil];
tabBarMore.navigationController.navigationBar.titleTextAttributes = textAttributes;
tabBarMore.navigationController.navigationBar.topItem.title = @"More";
UITableView *moreTableView = (UITableView *)tabBarController.moreNavigationController.topViewController.view;
int n = (int)[((UITableView *)tabBarMore.view) numberOfRowsInSection:0];
for (int i = 0; i < n; i++)
{
UITableViewCell *cell = [((UITableView *)tabBarMore.view) cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]];
[cell setBackgroundColor:[UIColor colorWithRed:20.0/255.0 green:41.0/255.0 blue:97.0/255.0 alpha:1]];
static NSString *cellId = @"Cell";
cell = [((UITableView *)tabBarMore.view) dequeueReusableCellWithIdentifier:cellId];
}
定義靜態單元格后設置背景。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.