ios - 带有 UIDatePicker subview 的 UIActionSheet 有一个小的透视区域

标签 ios uiview uidatepicker uiactionsheet

我正在尝试将 UIDatePicker View 放入 UIActionSheet 中。你可以在这里看到我遇到的问题。即使那里没有键盘,您仍然可以透过那个点看到背景。我在下面包含了当用户点击屏幕上的按钮时调用的代码。澄清一下,作为背景的 View Controller 是一个具有自己的导航层次结构的模态视图 Controller 。除了这个问题(这不是那么重要),但我想将两个选择按钮移到日期选择器下方。有没有简单的方法可以做到这一点? enter image description here

//How I initialized the action sheet
dateActionSheet = [[UIActionSheet alloc] initWithTitle:@"Choose Date" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Done", nil];

//This code gets called when the user taps a button on the screen
datePicker.datePickerMode = UIDatePickerModeDate;   //UIDatePicker datePicker
[dateActionSheet addSubview:datePicker];        
[dateActionSheet showInView:self.view];

CGRect menuRect = dateActionSheet.frame;
CGFloat orgHeight = menuRect.size.height;
menuRect.origin.y -= 214; //height of picker
menuRect.size.height = orgHeight+214;
dateActionSheet.frame = menuRect;


CGRect pickerRect = datePicker.frame;
pickerRect.origin.y = orgHeight;
datePicker.frame = pickerRect;

最佳答案

来自UIActionSheet class reference :

UIActionSheet is not designed to be subclassed, nor should you add views to its hierarchy.

相反,创建您自己的 View ,或使用第三方库,如 RMDateSelectionViewController .

关于ios - 带有 UIDatePicker subview 的 UIActionSheet 有一个小的透视区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20306816/

相关文章:

iphone - 如何隐藏或删除顶部的导航栏?

ios - 对数组中的数据进行排序

ios - 制作具有不同宽度和高度的 UIView 的圆形

iphone - UIDatePicker 仅显示月份和日期

iphone - XCode:当用户点击 UITextbox 时显示 UIDatePicker

android - 在移动 iOS 和 android 上停止 overflow-x

iphone - 如何使用 [self.view addSubview : myView] where myView is subclass of UIView? 添加 subview

iphone - MPMediaPickerController 在一个 View 中,MPMediaPlayback 在另一个 View 中。如何?

javascript - JQuery Datepicker 需要触发 onclick

ios - 如何通过 Mailcore/Libetpan 设置电子邮件 IMAP SEEN 标志