UITextView 和 UIPickerView 都有自己的 UIToolbar
我喜欢在我自己的应用程序中复制 iPhone 上 Safari 的表单行为。 如果您在 Web 表单中输入数据,您将在 UIKeyboardView 上方获得一个单独的 UIToolbar(上一个、下一个、完成)。 选择选项也是如此:您会在 UIPickerView 上方得到相同的 UIToolbar。
我正在寻找如何实现这一点的演示/源代码/想法。 我会使用该工具栏和文本视图/选择器视图创建自己的子视图吗? 有更优雅的方式吗? 特别是利用 UITextfield 的 beginResponder 的东西?
I like to replicate the form behavior of Safari on the iPhone in my own app. If you enter data in an web form you get a separate UIToolbar (previous, next, done) just above the UIKeyboardView. Same for choosing an option: you get the same UIToolbar just above an UIPickerView.
I am looking for demos / sourcode / ideas how to implement this. Would I create my own subview with that toolbar and textview / pickerview? Is there a more elegant way? Especially something that leverages becomeFirstResponder of UITextfield?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
所以我创建了一个 UIViewCOntroller 子类来管理它。
对此我编写了这个函数来添加。
然后我在 IB 中创建了视图,这是我的类标题最后的样子。 (视图上还有一个 UItoolbar,我只是在控制器中没有引用它)
然后隐藏我使用的视图。
最后但并非最不重要的一点是选择器的所有委托函数。
这就是工具栏的制作方法。 基本上我使用与 ViewController 子类相同的概念,并且我不使用标准的推送视图或模式显示选项。 (这里的示例实际上在键盘顶部放置了一个文本框和一个工具栏。
@interface BugEditCommentController : UIViewController {
UITextView* 评论;
UIToolbar* 工具栏;
}
-(void) addToViewWithAnimation:(UIView*) theView;
要激活此视图,通常您可以调用 [object comeFirstResponder];
因此,如果将其添加到视图控制器构造函数中,您所需要做的就是调用 [objectbecomeFirstResponder];
abd 如果您在控制器上实现此方法(在上面的代码中定义),
希望附加信息有所帮助。
So i created a UIViewCOntroller subclass to manage this.
on that i wrote this function to add.
I then created the view in IB, here is what my class Header looked like at the end of that. (there is also a UItoolbar on the view i just do not have a reference to it in my Controller)
To then hide the view i use.
And last but not least all the delegate functions for the picker.
This is how you do the ToolBar. Basically i use the same concept with a ViewController subclass, and i dont use the standard push view or modal display options. (the example here actually places a Textbox and a toolbar on top of the keyboard.
@interface BugEditCommentController : UIViewController {
UITextView* Comment;
UIToolbar* Toolbar;
}
-(void) addToViewWithAnimation:(UIView*) theView;
To activate this view usually you would call [object becomeFirstResponder];
so if you add this to your view Controller constructor, all you need to do is call [object becomeFirstResponder];
abd if you implement this method on your controller (defined in the above code)
hope the additional info helps.
我也在寻找这个问题的解决方案。
我发现这是最好的解决方案,您可以使用此 SCKit 添加工具栏来根据需要关闭 UIPickerView 或 UIDatePicker。
以下是 github 链接: https://github.com/scelis/SCKit/tree/
有乐趣!
I'm looking for the solution for this issue too.
I found this was the best solution, you can use this SCKit to add tool bar to dismiss the UIPickerView or the UIDatePicker as you want.
Following is github link: https://github.com/scelis/SCKit/tree/
Have fun!