Reputation: 8188
I have a picker returning 3 components. I was told you can change the size of the views by doing the following, but I am not too sure how to implement this... implementing the UIPickerViewDelegate method pickerView:widthForComponent: method to size the components (probably 150, 20, and 150, or so).
I see in the documentation you set up a method like this, but dont know what to do next?
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component
{
}
Upvotes: 0
Views: 345
Reputation: 8564
For using this you have to implement UIPickerViewDelegate
...... and assign it to your pickerView
.....
if this method is being written in the same class where you are creating pickerView
......
then write.....
pickerView.delegate = self;
and in header implement this delegate...
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component
{
if(component == 0)
return 150.0;
else if(component == 1)
return 20.0;
else if(component == 2)
return 150.0;
else
return 150.0;
}
Components are numbered left-to-right.
Thanks,
Upvotes: 2