![](/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.