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];
UIPickerViewDataSourceメソッドを実装します。
– numberOfComponentsInPickerView:
– pickerView:numberOfRowsInComponent:
およびUIPickerViewDelegateメソッド:
– 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
、データを埋めるために文字列で満たされたを使用します。それが役立つことを願っています!