![](/img/trans.png)
[英]How can I set the background of UITableView (the tableview style is “Grouped”) to use an image?
[英]How can I programmatically set a TableView to be grouped
我正在尝试从配置文件动态设置我的TableView,并且一直在尝试覆盖以下模板代码
- (id)initWithStyle:(UITableViewStyle)style {
// Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
JeanieAppDelegate *appDelegate = (JeanieAppDelegate *)[[UIApplication sharedApplication] delegate];
if (self = [super initWithStyle:(UITableViewStyle*)appDelegate.skin.tableViewStyle]) {
//1 if (self = [super initWithStyle:UITableViewStyleGrouped]) {
//2 if (self = [super initWithStyle:style]) {
}
return self;
}
2条注释行有效(模板随附2条注释行)。 我已经使用默认枚举定义了变量,如下所示:
@interface Skin : NSObject {
UITableViewStyle *tableViewStyle;
}
@property (nonatomic) UITableViewStyle *tableViewStyle;
@end
但是我的代码返回了一个不兼容的类型错误,为什么有什么主意?
UITableViewStyle不是指针类型
@interface Skin : NSObject {
UITableViewStyle tableViewStyle;
}
@property (nonatomic) UITableViewStyle tableViewStyle;
@end
而且您不需要将其强制转换为那里的超级方法的参数。 编译器应该知道它是什么类型。
[super initWithStyle:appDelegate.skin.tableViewStyle]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.