1

I am using Xcode 4.2 for my programming work. In my task, I preferred the users to make choices through the combo box in their iPad2. However, I cannot find the combo box button in the library. Do I miss some setting so that I cannot find the button? Does the combo box button be supported in the iPad2 platform? Also, I am using iPad 5.0 simulator.

4

1 回答 1

2

Combo boxes are not standard UIKit controls. They're used only in web views and in Mobile Safari. Apple's provided alternative is to use UIPickerView to allow for selections like that.

The typical design pattern is to tap some button or other interaction area to present a UIPickerView. When the user selects an item (either after the delegate is called) or the user taps a custom button you provide (e.g., "Select"), then the picker view is dismissed and the choice is made. For the iPad in particular, you are to embed a UIPickerView inside a UIPopoverController and present that to the user at some point. See the documentation for UIPickerView for more information as well as sample code provided by Apple.

Of course, if your UI is spacious enough, don't even bother presenting and hiding the picker view. Just show it all the time and let the user make choices that way. Of course, UIPickerView is rather large.

If you absolutely must have a combo box-like UI, then you're going to have to make it yourself or use a UIWebView embedded in your UI somewhere to present that data; however, the use of web views for things like this is probably not an ideal solution.

于 2011-09-14T06:54:03.093 回答