我正在尝试添加 PickerView - 但我看到黑屏......我做错了什么???
UIPickerView *myPickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 0, 320, 320)];
[self.view addSubview:myPickerView];
我正在尝试添加 PickerView - 但我看到黑屏......我做错了什么???
UIPickerView *myPickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 0, 320, 320)];
[self.view addSubview:myPickerView];
– numberOfComponentsInPickerView:
– pickerView:numberOfRowsInComponent:
– pickerView:titleForRow:forComponent:
不要忘记设置属性:
UIPickerView * myPickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 0, 320, 320)];
myPickerView.delegate = self;
myPickerView.dataSource = self;
[self.view addSubview:myPickerView];
在 .h 文件中,记得放:
<UIPickerViewDelegate, UIPickerViewDataSource>
我通常使用NSMutableArray
填充字符串来填充数据。希望有帮助!