Jer*_*rry 5 iphone uipickerview uiviewcontroller ios
嘿,我有一个视图,有一个按钮按下时应该模态呈现一个UIDatePicker.我有正确的选择器出现,但因为它是独立的UIView,它是全高,看起来很有趣.我想要的只是从用户那里得到一个非常快速的日期输入,更像是UIActionSheet一个UIView.
如何UIPicker只在模板上进行模拟,并在工具栏上进行一些操作,如完成等?
谢谢
您可以将其放在另一个具有透明背景的 UIView 上,或者更简单地,不要使用 PresentModalViewController,而是编写自己的例程以在当前视图中显示它。
// Untested code:
// put this in your current UIViewController (the one where you were going to call presentModalViewController:)
- (void)showPicker:(UIPickerView *) picker{
CGRect startFrame = picker.frame;
CGRect endFrame = picker.frame;
// Set the start position to below the bottom of the visible frame:
startFrame.origin.y = self.view.frame.size.height;
// Set the end position to slid up by the height of the view, so it will just fit:
endFrame.origin.y = startFrame.origin.y - endFrame.size.height;
picker.frame = startFrame;
[self.view addSubView:picker];
[UIView beginAnimations]
picker.frame = endFrame;
[UIView commitAnimations];
}
Run Code Online (Sandbox Code Playgroud)
当然,您需要添加所有必要的代码来保留指向选择器的指针,并跟踪何时显示和删除它。
| 归档时间: |
|
| 查看次数: |
2447 次 |
| 最近记录: |