开发者

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

- 开发者_如何学C(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). 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

@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]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜