开发者

to initialize selection bar in UIPickerview?

How can i initialize selection bar in UIPickerview, when i run it, it shows ,first row is selected with bar..how can i change the row inwhich selection bar must be there dynamically?

i have done like following ...its not working?

- (NSInteger)pickerView:(UIPickerView *)thePickerView nu开发者_运维知识库mberOfRowsInComponent:(NSInteger)component 

      {

        [psportPicker selectRow:3 inComponent:component animated:YES];
        return [citycount];


    }


[picker selectRow:[self.pickerData indexOfObject:indexToSelect] inComponent:0 animated:NO];

See the UIPickerView Class Reference for details.


You need to call selectRow from viewDidAppear on the parent view controller. I encountered the same problem when I was calling selectRow from viewDidLoad. Move your selectRow into viewDidAppear and the UIPickerView will respond appropriately.


Do you just want to select a certain row programmatically?

In that case, try -selectRow:inComponent:animated: (see the documentation for UIPickerView.


You can call selectRow from viewDidLoad after [super viewDidLoad] on the parent view controller. Your UIPickerView property should be properly initialized at that point.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜