- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 TableView ,其中嵌入了用于输入一些数据的 UITextFields。它还具有另外两个字段,用于弹出 UIPickerView 和 UIDatePicker - 如 Apple 的 DateCell 示例所示。
大多数情况下它可以工作,但我不知道如何干净地从文本字段键盘过渡到其他选择器 - 一个滑出,一个滑入 - 它看起来很奇怪,并且表格 View 上的滚动位置有时会搞砸- 所有内容都从顶部滚动。
我想做的是替换文本字段键盘,而不使其动画消失,也不将表格 View 恢复到完整大小。
有什么线索吗?
最佳答案
首先,这是一个 screencapture showing how this looks .
实现 UITextFieldDelegate 并显示包含 UIPickerView 的“弹出窗口”。
- (void)textFieldDidEndEditing:(UITextField *)textField {
UIPickerView *picker = [[UIPickerView alloc]
initWithFrame:CGRectMake(0, 244, 320, 270)];
picker.delegate = self;
picker.dataSource = self;
[self.view addSubview:picker];
[picker release];
}
当键盘消失时,选择器 View 就会可见。
如果您想更进一步,您可以像键盘一样为 UIPickerView“滑入”设置动画。
- (void)viewDidLoad {
//picker exists in the view, but is outside visible range
picker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 480, 320, 270)];
picker.delegate = self;
picker.dataSource = self;
[self.view addSubview:picker];
[picker release];
}
//animate the picker into view
- (void)textFieldDidEndEditing:(UITextField *)textField {
[UIView beginAnimations:@"picker" context:nil];
[UIView setAnimationDuration:0.5];
picker.transform = CGAffineTransformMakeTranslation(0,-236);
[UIView commitAnimations];
}
//animate the picker out of view
- (void)textFieldDidBeginEditing:(UITextField *)textField {
[UIView beginAnimations:@"picker" context:nil];
[UIView setAnimationDuration:0.5];
picker.transform = CGAffineTransformMakeTranslation(0,236);
[UIView commitAnimations];
}
//just hide the keyboard in this example
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return NO;
}
关于iphone - 用 UIPickerView 优雅地替换 iPhone 键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1275633/
我正在编写一个汽车租赁应用程序,用户必须指定取车和还车位置。 第一步,用户必须选择取货/返回办公室的区域/区域。选择区域后,他必须从该区域可用的办事处列表中进行选择。 为了选择办公室,我使用了 4 个
我正在尝试创建一个文本框,当选择该文本框时,UIPickerView 将打开并提供可供选择的选项。选择后,UIPickerView 将隐藏,所选项目将显示在文本框中。当我运行此程序时,数组中的第一个元
我有多个 UIPickerView 的问题,我在 UICollectionView 上有 8 个,当我滚动第一个 PickerView 和第五个 PickerView 时,它开始自行滚动并采用与第一个
我正在阅读一本 Swift OOP 书籍,我理解实例方法具有将在函数中使用的参数的想法。不清楚的是,在遵循 UIPickerViews 和 UITableViews 的在线教程时,有些方法将 UIPi
我有两个不同的 UIPickerView用户选择第一个 UIPickerView来自 didSelectRow第一个选择器,我得到第二个的输入 UIPickerView .我尝试为单个选择器设置标签,
函数 pickerView() 在 ViewLoad 上调用的代码 private func createPickerView(){ picker = UIPickerView(frame:
我创建了 UIPickerView 如下。现在我想让它 resignFirstResponder 如果用户在其他地方点击然后 UIPickerView 我怎么能实现呢。我已经按照以下方式创建了 UIP
我的 View Controller 中有两个 UIPickerview,pickerView1 和 pickerView2。 我在这里想要实现的是,当我从 pickerView1 中选择一个字符串时
我们正在使用 UIPickerView允许用户从选项列表中进行选择。我们正在添加 UIPickerView作为容器 UIView 的 subview 。然后我们将一个 UITapGestureReco
好吧,我不知道如何处理这个问题。 我有一个 UITextField,我根据 XML 文件的定义将其动态添加到 UITableView,在 XML 文件中,我可以将列表指定为其中一种数据类型,然后我所做
我现在有2个UIPickerView,以后想再添加3个,代码如下: -(void)viewDidLoad{ Pos_x = 5; Pos_y = 70; for (i= 0; i<2; i++) {
UIPickerView 的 selectRow:inComponent:animated:调用pickerView:didSelectRow:inComponent: ? 否则,我可以自己打电话吗?
我有两个按钮,打开一个 UIPickerView @IBOutlet weak var convertFromButton: UIButton! @IBOutlet weak var convertT
祝大家有美好的一天 我尝试在主题行中解释我的查询。据我了解,从代码中看到,所有 pickerview 都在 ViewDidLoad() 中初始化,这意味着它们都有自己的数据集。作为数据验证的一部分(在
我试图在 PickerView 中显示血型,但由于某些原因,选项仅显示为问号! 这是我的代码: class RegisterViewController: UIViewController,
我正在尝试将工具栏添加到 UIPicker . 我已经看到正确的方法是这样: UIToolbar* toolbarWeight= [[UIToolbar alloc] initWithFrame:CG
我将如何向 uipickerview 添加手势事件来更改选项卡?我必须创建一个自定义类,但是,我不知道如何处理 uipickerview。我当前在 uiviews 中存在手势来执行此操作,但我在使用
我想做的是: 显示了一个 UIPickerView。如果用户触摸选定的行,则该行将被锁定(它是多组件选择器),并且其他组件可以自由旋转。如果该行已被锁定并且用户触摸了锁定的行,则该行将被解锁并可以自由
我有两种看法。第一个:第一个 View Controller 第二:SecondViewController FirstView Controller 是我的 UINavigationControll
使用 UISegmentedControl,您可以在不选择任何内容的情况下启动它。如何使用 UIPickerView 做到这一点?看起来显示默认为索引 0。 谢谢 最佳答案 选择器轮必须停留在某些值上
我是一名优秀的程序员,十分优秀!