无法将 UIDatePicker 添加到 UIActionSheet

发布于 2024-12-07 14:59:32 字数 1082 浏览 1 评论 0原文

我想将 UIDatePicker 添加到 UIActionSheet 中,代码如下:

UIActionSheet* actionSheet = [[UIActionSheet alloc] initWithTitle:@"DEMO" delegate:self cancelButtonTitle:@"Cancle" destructiveButtonTitle:nil otherButtonTitles:nil];


 actionSheet = [[UIActionSheet alloc] initWithTitle:@"Ratings" 
                                                  delegate:self
                                         cancelButtonTitle:@"Cancel"
                                    destructiveButtonTitle:nil
                                         otherButtonTitles:nil];

UIDatePicker *pickerView = [[UIDatePicker alloc] init];
pickerView.datePickerMode = UIDatePickerModeDate;

[actionSheet addSubview:pickerView];
[actionSheet showInView:self.view];   
[actionSheet sendSubviewToBack:pickerView];  

[actionSheet showInView:self.view];
[actionSheet setBounds:CGRectMake(0,0,320, 500)];

CGRect pickerRect = pickerView.bounds;
pickerRect.origin.y = -100;
pickerView.bounds = pickerRect;

[pickerView release];
[actionSheet release];

问题是为什么此代码不能在 iPad 模式下工作,而在 iphone 模式下可以工作

I want to add a UIDatePicker to a UIActionSheet, the code is below:

UIActionSheet* actionSheet = [[UIActionSheet alloc] initWithTitle:@"DEMO" delegate:self cancelButtonTitle:@"Cancle" destructiveButtonTitle:nil otherButtonTitles:nil];


 actionSheet = [[UIActionSheet alloc] initWithTitle:@"Ratings" 
                                                  delegate:self
                                         cancelButtonTitle:@"Cancel"
                                    destructiveButtonTitle:nil
                                         otherButtonTitles:nil];

UIDatePicker *pickerView = [[UIDatePicker alloc] init];
pickerView.datePickerMode = UIDatePickerModeDate;

[actionSheet addSubview:pickerView];
[actionSheet showInView:self.view];   
[actionSheet sendSubviewToBack:pickerView];  

[actionSheet showInView:self.view];
[actionSheet setBounds:CGRectMake(0,0,320, 500)];

CGRect pickerRect = pickerView.bounds;
pickerRect.origin.y = -100;
pickerView.bounds = pickerRect;

[pickerView release];
[actionSheet release];

The question is why this code cannot work in iPad mode while it is ok in iphone mode

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心安伴我暖 2024-12-14 14:59:32

我会尝试使用 EAActionSheetPicker。它会为你处理这些事情。

I would try using EAActionSheetPicker. It handles that for you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文