ios - 更改嵌入在 iOS 5 上的 UIViewController 中的 UITableView 的背景

标签 ios uitableview ios5 xcode4.2

我正在尝试将嵌入式 UITableView 上的灰色渐变背景更改为我在 Storyboard 的父 View 上设置的颜色。

我一直在环顾四周,发现以下线程:

  • Change iPhone tableview (style grouped) background color while preserving texture
  • How can I set the background of UITableView (the tableview style is “Grouped”) to use an image?
  • UITableView backgroundColor always gray on iPad

  • 我在连接两个 View 的父 Controller 中有一个 IBOutlet。

    我的实现如下所示:
    - (void)viewDidLoad {
        [super viewDidLoad];
        [activeShipmentsTable setBackgroundView:nil];
        [activeShipmentsTable setBackgroundView:[[[UIView alloc] init] autorelease]];
        [activeShipmentsTable setBackgroundColor:UIColor.clearColor];
    }
    

    我究竟做错了什么?

    谢谢。

    最佳答案

    尝试在表格的背景 View 上设置背景颜色,而不是表格本身。

    UIView *view = [[[UIView alloc] init] autorelease];
    view.backgroundColor = [UIColor redColor];
    self.tableView.backgroundView = view;
    

    关于ios - 更改嵌入在 iOS 5 上的 UIViewController 中的 UITableView 的背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8962726/

    相关文章:

    ios - Swift - 使用 [String : [String: String]] 的字典填充 uitableview

    iphone - 同一商场中两家商店之间的最短路径绘制

    iOS 5 不会重定向到 Appstore

    ios - 文件未使用 NSFileProviderExtension 显示

    objective-c - 秒表显示问题

    ios - UINavigationBar下的多个UITableView

    ipad - UIBarButtonItem + popover segue 创建多个弹出框

    ios - 崩溃 : storyboardWithName:

    ios - Twitter Kit/Fabric “Show Timeline” Objective-C 示例构建失败

    ios - 禁用内部时嵌套 UITableViews : a way to scroll only the outer UITableView,?