为什么带有 UIDatePicker 的自定义 UIActionSheet 的下半部分被禁用?

发布于 2024-09-05 15:35:25 字数 1153 浏览 5 评论 0原文

我的 UIActionSheet 包含 UIDatePicker,除了 DatePicker 的下半部分被禁用之外,一切似乎都运行良好。从视觉上看,有一个阴影使选择器的下半部分比上半部分更暗。下半部分的所有内容都被禁用,我一生都无法弄清楚如何启用它。

我还注意到在其他仅包含按钮的“正常”UIActionSheets 中,取消按钮的下半部分被禁用。

这是我的自定义 UIActionSheet 的代码:

self.datePickerView = [[UIDatePicker alloc] init];
self.datePickerView.datePickerMode = UIDatePickerModeDate;

self.actionSheet = [[UIActionSheet alloc] initWithTitle:@"Choose a Follow-up Date"
                   delegate:self cancelButtonTitle:nil 
                   destructiveButtonTitle:nil otherButtonTitles:@"Done", nil];

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

CGRect pickerRect = self.datePickerView.bounds;
pickerRect.origin.y = -95;
self.datePickerView.bounds = pickerRect;

我已经尝试了几件事,包括 sendSubviewToBack、BringSubviewToFront 等,但我没有任何运气。我感谢你的帮助!

这是一个屏幕截图。我添加了红色框以进行澄清。 替代文本 http://gorgando.com/UIActionSheet%20Problem.png

Everything seems to be working great with my UIActionSheet that contains a UIDatePicker except that the bottom half of the DatePicker is disabled. Visually there is a shadow that makes the bottom half of the picker darker than the top half. Everything in the bottom half is disabled and I can't for the life of me figure out how to enable it.

I also noticed in my other "normal" UIActionSheets that just contain buttons, the bottom half of the cancel buttons are disabled.

This is the code for my custom UIActionSheet:

self.datePickerView = [[UIDatePicker alloc] init];
self.datePickerView.datePickerMode = UIDatePickerModeDate;

self.actionSheet = [[UIActionSheet alloc] initWithTitle:@"Choose a Follow-up Date"
                   delegate:self cancelButtonTitle:nil 
                   destructiveButtonTitle:nil otherButtonTitles:@"Done", nil];

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

CGRect pickerRect = self.datePickerView.bounds;
pickerRect.origin.y = -95;
self.datePickerView.bounds = pickerRect;

I've tried several things including sendSubviewToBack, BringSubviewToFront, etc but I have not had any luck. I appreciate your help!

Here is a screenshot. I added the red boxes for clarification.
alt text http://gorgando.com/UIActionSheet%20Problem.png

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

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

发布评论

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

评论(2

下雨或天晴 2024-09-12 15:35:25

尝试在 UIDatePicker 上设置框架而不是边界。我认为当您将原点设置为 -95 来定位它时,会发生一些奇怪的事情。

Try setting the frame on your UIDatePicker instead of the bounds. I think you've got some weird stuff going on when you set the origin to -95 to position it.

梦冥 2024-09-12 15:35:25

确保使用适当的 showXXX 函数 - 当从 UITabBar 显示操作表时,我遇到了类似的问题;因此在本例中使用了 UIActionSheet 方法 -showFromTabBar:

Make sure you show your action sheet with the appropriate showXXX function - I had a similar problem when showing an action sheet from a UITabBar; so in this case used UIActionSheet method -showFromTabBar:.

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