有人知道如何像键盘一样在UIDatePicker中滑动吗?

时间:2009-08-28 14:56:30

标签: objective-c iphone animation uidatepicker

有没有人知道如何使用键盘控件之类的完成按钮在UIDatePicker中滑动?如果是这样,你可以分享一些示例代码。谢谢

2 个答案:

答案 0 :(得分:1)

我建议您使用UIViewController,并以模态显示。

创建UIViewController并使用Interface Builder中的OK按钮设置视图,就像对任何视图控制器一样。

使用以下方式显示:

- (void)presentModalViewController:(UIViewController *)modalViewController 
                          animated:(BOOL)animated

如果希望透明,可以将根视图背景设置为清除。并且当转换完成时,可选地将其设置为透明黑色。像这样的东西会起作用:

- (void)viewDidAppear:(BOOL)animated {
  if (animated) [UIView beginAnimations:@"fadeDark" context:NULL];
  self.view.backgroundColor = [UIColor colorWithWithe:0.0f alpha:0.5f];
  if (animated) [UIView commitAnimations];
}

答案 1 :(得分:0)

1.创建UIButton类的子类

2.redeclare inputview as read-write

@property (nonatomic, strong, readwrite) UIView *inputView;

3.set canBecomeFirstResponder为YES

- (BOOL)canBecomeFirstResponder {
return YES;
}

4.将inputview设置为datepicker

self.inputView = self.datePicker;

5.在您需要时将UIResponder设置为firstResponder

[self becomeFirstResponder];

5.你可以在键盘上看到日期选择器幻灯片