如何在UIActionSheet中添加UIPickerView
我有任务输入评级(1 - 5)值,所以我找到了下面的日期选择器代码,任何人都可以帮助我更改下面的代码,以便添加 UIPickerView 以选择从 1 到 5 的评级,
UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:@"Ratings"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:nil];
UIDatePicker *pickerView = [[UIDatePicker alloc] init];
pickerView.datePickerMode = UIDatePickerModeDate;
[menu addSubview:pickerView];
[menu showInView:self.view];
[menu sendSubviewToBack:pickerView];
[menu setBounds:CGRectMake(0,0,320, 500)];
CGRect pickerRect = pickerView.bounds;
pickerRect.origin.y = -100;
pickerView.bounds = pickerRect;
[pickerView release];
[menu release];
该怎么做文本字段评级将自动输入 UIPIckerView 中选择的值,
谢谢
i'm having task to enter rating(1 - 5) value, so i found the below code for date picker, can anyone help me to alter below code so to add UIPickerView to choose rate from 1 to 5
UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:@"Ratings"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:nil];
UIDatePicker *pickerView = [[UIDatePicker alloc] init];
pickerView.datePickerMode = UIDatePickerModeDate;
[menu addSubview:pickerView];
[menu showInView:self.view];
[menu sendSubviewToBack:pickerView];
[menu setBounds:CGRectMake(0,0,320, 500)];
CGRect pickerRect = pickerView.bounds;
pickerRect.origin.y = -100;
pickerView.bounds = pickerRect;
[pickerView release];
[menu release];
what to do so text field for ratings will auto entered with selected value from UIPIckerView
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
首先,我认为您可能会将 UIPickerView 与 UIDatePickerView 混淆。日期选择器是一个特殊的选择器,无法自定义,而 UIPickerView 是专门为自定义而设计的。 Marc W 的评论是正确的。我之前回答过这个问题并且觉得它提供了比尝试将选择器添加到 UIActionSheet 更好的解决方案。
有很多 UIPickerView 教程。
First of all, I think you might be confusing a UIPickerView with a UIDatePickerView. The date picker is a specialized picker that can't be customized while a UIPickerView is made specifically to be customized. Marc W is right in his comment. I answered this question before and feel it offers a better solution than trying to add the picker to the UIActionSheet.
There are lots of UIPickerView tutorials out there.
该解决方案适用于横向和 4 英寸屏幕。
This solution works in landscape and on the 4 inch screens.