为什么带有 UIDatePicker 的自定义 UIActionSheet 的下半部分被禁用?
我的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试在 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.
确保使用适当的
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 aUITabBar
; so in this case usedUIActionSheet
method-showFromTabBar:
.