开发者

how to display UIPickerview in dialog box

I am new to 开发者_Go百科iPhone.

I need to display UIPickerview in UIAlertView and I need to get UIPickerview selected value.

Can anyone please post some code or link?


I will not do it.

  1. I am afraid it is not possible to 'pack' UIPickerView into UIAlertView. UIPickerView seems to be always AS wide AS the whole screen (at least on the iPhone) - so even if you manage to add the picker as a subview, it will cover the alert.
  2. I think it will spoil Apple Human Interface Guidelines.

Why do you insist to present a picker in alert? Can't you present it alone, without alert?


I would strongly recommend not doing that. Use the picker view as it's intended—as it's used in Clock and Calendar, i.e. at the bottom of the screen—and you're much less likely to get your app rejected by Apple for violating their Human Interface Guidelines.


As for the alert, you could create something yourself that looks similar, but I don't see why you'd want to combine a alert and a datePicker.

To access the datePicker's date, you need to have it declared in your code. Then you can simply use this:

NSDate *date = self.datePicker.date;

To get the date from a datePicker named datePicker.

To get this date into a string, which you probably want, do this:

NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease];
[formatter setDateFormat:@"dd MMM, yyyy"];
NSString *stringFromDate = [formatter stringFromDate:date];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜