如何在 UIPopoverController 中设置 UITableView 的背景颜色?

发布于 2024-10-11 19:29:21 字数 288 浏览 13 评论 0原文

我正在使用 iOS SDK 4.2。我有一个使用导航控制器初始化的 UIPopoverController,该导航控制器使用视图控制器初始化。视图控制器的子视图之一是分组表视图。我想更改表格视图的背景颜色。但是,如果我在视图控制器的 viewDidLoad 方法中执行此操作,则

self.myTableView.backgroundColor = [UIColor blackColor];

背景不会更改,当弹出窗口出现时,表视图的背景为灰色。有什么线索吗?这种方法有什么问题吗? 先感谢您。

I am using iOS SDK 4.2. I have an UIPopoverController initialized with a navigation controller which is initialized with a view controller. One of the subviews of the view controller is a grouped table view. I would like to change the background color of the table view. However, if I do in the viewDidLoad method of the view controller

self.myTableView.backgroundColor = [UIColor blackColor];

the background does not changes, when the popover appears, the background of the table view is gray. Any clue? What's wrong with this approach?
Thank you in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

弱骨蛰伏 2024-10-18 19:29:21

分组表视图在 backgroundView 属性中有一个自定义视图。该自定义视图显示背景。如果您想更改背景,您应该创建自己的视图并将其分配给那里。就您而言,您可能需要如下所示的内容:

UIView *bgView = [[[UIView alloc] init] autorelease];
bgView.backgroundColor = [UIColor blackColor];
bgView.opaque = YES;
self.myTableView.backgroundView = bgView;

Grouped table views have a custom view in the backgroundView property. This custom view is what displays the background. If you want to change the background, you should create your own view and assign it there. In your case, you probably want something like the following:

UIView *bgView = [[[UIView alloc] init] autorelease];
bgView.backgroundColor = [UIColor blackColor];
bgView.opaque = YES;
self.myTableView.backgroundView = bgView;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文