How to create drop down list box for an iphone app
I need to add dropdown list box for an iphone app. I couldn’t find this object in the library. Instead there is picker view, but i need compact object like dropdown list box开发者_开发技巧. Please suggest me how to add or create this.
Thanks in advance.
No such thing exists. You can either create your own control, or use UIPicker. Creating your own drop-down control is quite a bunch of work, compared to using the Picker, and unless that particular control is mission-critical, I'd recommend you figure out how to use UIPicker inside your existing design. Not only does it already exist, but users are familiar with it and know how to use it. There really is a point to Human Interface Guidelines and a standard set of UI elements.
In situations where I've needed a picker-like control in a small amount of space, I've used a label and a button that brings up another view containing the picker. You can slide that in using UINavigationController, or just present the view modally. That's how I mostly see apps handling this.
EDIT: Or use UIActionSheet like @Lou Franco says. That's a pretty good option too.
Usually, you see either a UIActionSheet, like this
Creating iPhone Pop-up Menu Similar to Mail App Menu
Or a another view slide in with the choices. It depends on whether you have a small finite number or a long or unbounded list.
You can make a custom view like action sheet or alert view. I did a custom view like alert view. It will be shown on the center and block any touch behind it. And give a list buttons, which are drawn on the UIScrollView, for user to select one desired option.
Here is another alternative. The action sheet is basically a drop down list if you think about it. And if you keep adding buttons to a UIActionSheet it ends up turning into a table. So just have a UIButton (or some event) trigger the UIActionSheet.
Try adding 7 or more buttons to the UIActionSheet and watch it turn into a list. Its convenient.
1) create one textField and set it disable
2)near of text field add one button with arraw image.
3) create one view which will have one toolBar with two button @"done", cancel .set this toolbar to view then add one pickerview. set view frame y position to more then device height.
now on button action apply the animation to show the view from down to up(show picker view)
on done and cancel button again apply the animation to show the view from up to down(hide view)
The reason a compact list view probably does not exist in the iOS frameworks is because they might be too hard to use with a fat finger. The user's finger will block multiple selections, so they can't see any selections while selecting, and they will hit the wrong selection because the target is too small.
Action sheets and picker views provide nice big finger sized targets for even fat fingers, and a way to scroll the bigger selection targets that would be off-screen if there are more than just a few choices.
If you can create a custom pop-up view that can handle all these problems, then you can roll your own control.
-(IBAction)dropButtonAction
{
if(dropBtnFlag==TRUE){
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
[dropView setFrame:CGRectMake(121,122,179,122)];
[UIView commitAnimations];
dropFlag=FALSE;
}
else {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
[dropView setFrame:CGRectMake(121,122,179,0)];
[UIView commitAnimations];
dropFlag=TRUE;
}
}
here "dropView" is UIViewController.
精彩评论