我正在尝试为加载在 UINavigationController 中的许多 UITableView 设置背景。我正在使用 iOS 5 中添加的外观代理,但它无法正常工作。
该应用程序使用 UISplitViewController,主 View 是 UINavigationController。
在这里面,我有一个 UITableViewController 子类,叫做 PBMasterTableViewController。
在我的 AppDelegate 中,我有以下内容:
UIImageView *bgView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"menuBg.png"]] autorelease];
[[UITableView appearanceWhenContainedIn:[PBMasterTableViewController_Ipad class], nil] setBackgroundView:bgView];
这工作正常,我在拆分 View 中的主菜单具有我想要的背景。
从这个主菜单中,当我选择相关行时,我将其他 3 个 UITableViewController 子类推到导航 Controller 上。但是,我无法使用外观代理更改这些表的背景。我正在尝试以下操作:
UIImageView *bgView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"menuBg.png"]] autorelease];
[[UITableView appearanceWhenContainedIn:[PBTwitterTableViewController class], nil] setBackgroundView:bgView];
这也在前面显示的代码正下方的 appDelegate 中起作用(但是没有重复创建 ImageView )但这根本没有任何作用!当我将 PBTwitterTableViewController 的一个实例推送到导航 Controller 上时,我只是获得了一个没有背景变化的标准表格 View 。
我知道我可以简单地更改 tableViewControllers 本身中的背景 View ,但是当旋转到 portait 时,当菜单显示在 splitViewControllers 弹出窗口中时,我不希望这些背景在那里,因此我尝试使用appearanceWhenContainedIn:
我也不想简单地将外观设置为包含在 UISplitViewController 中,因为在 2 个实例中我有一个 UITableView 被加载到细节部分,所以这会改变那些我不想要的外观。
是否有另一种方法可以在没有外观代理的情况下仍然允许我更改弹出窗口中的背景,或者是否有办法使用代理进行此操作,或者我只是错过了一些愚蠢的东西?
谢谢
编辑 :
我刚刚尝试创建 UINavigationController 的子类并尝试使用
[[UITableView appearanceWhenContainedIn:[PBMenuNavigationController class], nil] setBackgroundView:bgView];
这对于主菜单再次正常工作,但不适用于推送到堆栈上的任何其他 UITableView,所以我现在真的很难过:(
最佳答案
确定排序。只是在每个 View 中执行它并检查父 Controller 是否不是我不想要的东西。不管怎么说,还是要谢谢你
关于ios5 - ios5 UIAppearance 的 UITableView 外观无法正常工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9774838/