//如果不想用拉的宣告顯示資料位置,也在可在初始化這樣設定
//self.picker.dataSource = self;
//self.picker.delegate = self;
- (int)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 1;
}
//顯示選取資料筆數
- (long)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return list1.count;
}
// 顯示選取資料
- (NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
return [list1 objectAtIndex:row];
}
//顯示目前選取哪筆資料
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
NSLog(@"select:%@",[list1 objectAtIndex:row]);
}
沒有留言:
張貼留言