I added a picker view and the dataSource and delegate like this:
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return _datas.count;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
return _datas[component].count;
}
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component {
CGFloat width = SCREEN_W / _datas.count;
return width;
}
- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component {
return kActionPickerRowHeight;
}
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {
UILabel *label = [[UILabel alloc] init];
label.frame = CGRectMake(0, 0, SCREEN_W / _datas.count, kActionPickerRowHeight);
label.textAlignment = NSTextAlignmentCenter;
label.text = [NSString stringWithFormat:@"%@",_datas[component][row]];
label.font = [UIFont systemFontOfSize:12.f];
label.layer.borderWidth = 1.f;
return label;
}
But the picker display like this:
There is a white border about 150px at the right side.
I show the row's border and picker's border to debug