UIPickerView
//固定的大小 320×216.
self.genderTitleArray = @[@"神秘", @"女性", @"男性"];
self.gendervalueArray = @[@"UNKNOW", @"FEMALE", @"MALE"];
UIPickerView *genderPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 50, 0, 0)];
genderPicker.showsSelectionIndicator = YES;
genderPicker.backgroundColor = [UIColor whiteColor];
genderPicker.delegate = self;
genderPicker.dataSource = self;
[genderPicker selectRow:1 inComponent:0 animated:YES];
[genderPicker selectRow:1 inComponent:1 animated:YES];
self.gendervalueArray = @[@"UNKNOW", @"FEMALE", @"MALE"];
UIPickerView *genderPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 50, 0, 0)];
genderPicker.showsSelectionIndicator = YES;
genderPicker.backgroundColor = [UIColor whiteColor];
genderPicker.delegate = self;
genderPicker.dataSource = self;
[genderPicker selectRow:1 inComponent:0 animated:YES];
[genderPicker selectRow:1 inComponent:1 animated:YES];
[view addSubview:genderPicker];
#pragma mark - UIPickerViewDelegate UIPickerViewDataSource
// pickerView列数
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return 2;
}
// pickerView每列的个数
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
return 3;
}
//设置标题
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
if (component == 0) {
return self.genderTitleArray[row];
} else {
return self.gendervalueArray[row];
}
// pickerView列数
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return 2;
}
// pickerView每列的个数
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
return 3;
}
//设置标题
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
if (component == 0) {
return self.genderTitleArray[row];
} else {
return self.gendervalueArray[row];
}
}
posted on 2015-09-30 17:39 taiyang2014 阅读(128) 评论(0) 编辑 收藏 举报