我正在尝试将 UITableView 作为子视图添加到 UIViewController 的视图中,但出现错误:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Skema_Main___Controller setTableViewStyle:]: unrecognized selector sent to instance 0x9e41ce0'
这是我的代码:
Skema Main - Controller.h
@interface Skema_Main___Controller : UIViewController <UIPickerViewDelegate, UIPickerViewDataSource, UITableViewDataSource, UITableViewDelegate> {
UIPickerView *pickerView;
NSMutableArray *pickerArray;
}
// property and setter
@property (nonatomic) NSInteger week;
- (void)setWeekSelected:(NSInteger) weekSelected;
//UIPicker
@property (nonatomic, retain) UIPickerView *pickerView;
@property (nonatomic, retain) NSMutableArray *pickerArray;
//TableView
@property (nonatomic, retain) UITableView *skemaTableView;
// Main Dictionary
@property (nonatomic,strong) NSMutableDictionary *dataDictionary; // data
@end
Skema Main - Controller.m
(我从这里删除了很多不相关的东西,我也在使用 UIPickerView)
...
@synthesize skemaTableView;
...
- (void)viewDidLoad
{
[super viewDidLoad];
// Set picker for week
NSLog(@" %i", self.week);
[self generateView:self.week];
//TableView
float screenWidth = [UIScreen mainScreen].bounds.size.width;
skemaTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, screenWidth, 200) style:UITableViewStylePlain];
skemaTableView.dataSource = self;
skemaTableView.delegate = self;
[self.view addSubview:skemaTableView];
}
...