ios - UIDatePicker 未在 UITable 上正确显示
<p><p>我有一个 UITableCell 并且在该单元格上我有一个 UITextBox,当单击文本框而不是显示键盘时,将显示一个 UIDatePicker 并使用下面的代码。但我无法定位 UIDatePicker。我需要它从页面的最底部开始,此时它似乎从按下文本框的表格部分的顶部开始。当用户单击首选日期标签时,代码会触发。任何指针?我附上了一张图片来显示它当前的渲染位置。谢谢。</p>
<p> <img src="/image/T1qL1.png" alt="Issue"/> </p>
<pre><code>- (IBAction)selectDateBegin:(id)sender {
//Disable Keyboard
;
//Disable Scrolling
;
if () {
return;
}
CGRect toolbarTargetFrame = CGRectMake(0, self.view.bounds.size.height-216-44, 320, 44);
CGRect datePickerTargetFrame = CGRectMake(0, self.view.bounds.size.height-216, 320, 216);
UIView *darkView = [ initWithFrame:self.view.bounds];
darkView.alpha = 0;
darkView.backgroundColor = ;
darkView.tag = 9;
UITapGestureRecognizer *tapGesture = [ initWithTarget:self action:@selector(dismissDatePicker:)] ;
;
;
UIDatePicker *datePicker = [ initWithFrame:CGRectMake(0, self.view.bounds.size.height+44, 320, 216)] ;
datePicker.tag = 10;
;
;
UIToolbar *toolBar = [ initWithFrame:CGRectMake(0, self.view.bounds.size.height, 320, 44)];
toolBar.tag = 11;
toolBar.barStyle = UIBarStyleBlackTranslucent;
UIBarButtonItem *spacer = [ initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
UIBarButtonItem *doneButton = [ initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissDatePicker:)];
];
;
;
toolBar.frame = toolbarTargetFrame;
datePicker.frame = datePickerTargetFrame;
darkView.alpha = 0.5;
;
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>我建议你用这个指令替换你的 textField 的 inputView(默认是键盘):</p>
<pre><code>UIDatePicker *datePicker = [ init] ;
;
;
</code></pre>
<p>更合适且符合 Apple 人机界面指南</p></p>
<p style="font-size: 20px;">关于ios - UIDatePicker 未在 UITable 上正确显示,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/15310958/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/15310958/
</a>
</p>
页:
[1]