开发者

UIPicker specific question(iphone)

I am starting to learn to use the UIPicker in an application. what I want to do is that when the user clicks on the zipcode textbox, I want the uipicker to pop up and display list of zipcodes available. Just like a drop down in c# or VB.net. Do I have to create a new 开发者_JS百科view and place the uipicker there? Thanks


  1. You need a view for placing a text box. It does not matter if it needs to be a new view or the old view - just place the text box in the view you require.

  2. make sure that

    textField.inputView = yourPickerView;
    


In order to have a UIPickerView appearing in your app you do not need an additional view.

Assuming you are in a UIViewController:

@interface MyController : UIViewController {
    UIPickerView* mPicker;
}
-(void)showPicker;
-(void)hidePicker;
@end

-(void)showPicker {
    [self.view addSubview:mPicker];
    mPicker.center = CGPoint // set out of sight

    [UIView beginAnimations:nil context:nil];
    // do your transformations
    [UIView commitAnimations];
}

-(void)hidePicker {
    // do your exit animations
}

You can also add a delegate function to the second animations to remove the mPicker from the superview.

For more information have a look at the UIView Reference.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜