我希望你能帮我设置控制器的背景颜色。
奇怪的是,当我在Xcode 4.5.2中构建我的代码时,它看起来如下图所示。正如你可以看到背景颜色消失了它应该是(黄色)作为下一张图片
当我在Xcode 4.3.3中构建代码时,它看起来如下图所示。这就是它的外观。
我的代码是这样的:
------------------ InstantCabAppDelegate.m文件----------- START -------
//InstantCabAppDelegate.m file
orderController = [[OrderController2 alloc] initWithNibName:@"Order2" bundle:nil];
UINavigationController* firstnavigationController = [[UINavigationController alloc] initWithRootViewController:orderController];
------------------ OrderController2.m文件----------- START -------
//OrderController2.m file
- (void)viewDidLoad
{
[super viewDidLoad];
[self.tableView setBackgroundColor:TABLE_VIEW_BACKGROUND_COLOR];
[self.tableView setSeparatorColor:TABLE_VIEW_SEPARATOR_COLOR];
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];
self.parentViewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background-nologo"]];
UIView *logoParentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 75)];
UIImageView *logoView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"logo_order_page"]];
CGRect logoViewFrame = logoView.frame;
logoViewFrame.origin.x = (self.view.frame.size.width / 2) - (logoViewFrame.size.width / 2);
logoViewFrame.origin.y = 8;
[logoView setFrame:logoViewFrame];
[logoParentView addSubview:logoView];
self.tableView.tableHeaderView = logoParentView;
self.tableView.rowHeight = 50;
[self.navigationController.navigationBar setTintColor:NAVIGATION_BAR_TINT_COLOR];
[[MyLocation singleton] setDelegate:self];
[self reset];
UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 50)];
UIButton *orderButton = [UIButton buttonWithType:UIButtonTypeCustom];
[orderButton setFrame:CGRectMake(5, 0, footerView.frame.size.width - 10, 50)];
[orderButton setBackgroundImage:[UIImage imageNamed:@"yellow_btn"] forState:UIControlStateNormal];
[orderButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[orderButton setTitle:AMLocalizedString(@"kOrderOrderTaxiAlt", @"") forState:UIControlStateNormal];
[[orderButton titleLabel] setFont:[UIFont boldSystemFontOfSize:orderButton.titleLabel.font.pointSize]];
[orderButton addTarget:self action:@selector(checkOrder) forControlEvents:UIControlEventTouchUpInside];
[footerView addSubview:orderButton];
[self.tableView setTableFooterView:footerView];
isShowingModalViewController = NO;
}
答案 0 :(得分:0)
我是从Apple支持中得到的:
当表格视图的样式设置为UITableViewStyleGrouped时,UITableView会将背景视图应用于自身。背景视图用于绘制与该样式表视图关联的默认模式,但它也包含已设置的任何自定义背景颜色。您可以通过调用self.tableView.backgroundView = nil来删除此背景视图;来自viewDidLoad。这样做会使您的自定义背景颜色再次可见。
? Apple Inc. | Apple开发者技术支持