[英]How can I programmatically set a TableView to be grouped
I am trying to set up my TableView dynamically froma configuration file and have been trying to override the following template code 我正在尝试从配置文件动态设置我的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;
}
The 2 commented lines work (no 2 is one which comes with the template). 2条注释行有效(模板随附2条注释行)。 I have defined my variable using the default enum as follows:
我已经使用默认枚举定义了变量,如下所示:
@interface Skin : NSObject {
UITableViewStyle *tableViewStyle;
}
@property (nonatomic) UITableViewStyle *tableViewStyle;
@end
However my code return an incompatible type error, any ideas why? 但是我的代码返回了一个不兼容的类型错误,为什么有什么主意?
UITableViewStyle is not a pointer type UITableViewStyle不是指针类型
@interface Skin : NSObject {
UITableViewStyle tableViewStyle;
}
@property (nonatomic) UITableViewStyle tableViewStyle;
@end
And you shouldn't need to cast it in the argument to the supermethod there. 而且您不需要将其强制转换为那里的超级方法的参数。 The compiler should know what type it is.
编译器应该知道它是什么类型。
[super initWithStyle:appDelegate.skin.tableViewStyle]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.