以编程方式将iPhone键盘顶部的工具栏对齐 [英] Programmatically align a toolbar on top of the iPhone keyboard

查看:138
本文介绍了以编程方式将iPhone键盘顶部的工具栏对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在某些情况下,我想在iPhone键盘的顶部添加一个工具栏(例如,当您导航表单元素时,在iPhone Safari中)。

In several cases I want to add a toolbar to the top of the iPhone keyboard (as in iPhone Safari when you're navigating form elements, for example).

目前我使用常量指定工具栏的矩形,但是因为界面的其他元素是通用的 - 工具栏和导航栏在屏幕的顶部 - 每次我们做

Currently I am specifying the toolbar's rectangle with constants but because other elements of the interface are in flux - toolbars and nav bars at the top of the screen - every time we make a minor interface change, the toolbar goes out of alignment.

有没有办法以编程方式确定键盘相对于当前视图的位置?

Is there a way to programatically determine the position of the keyboard in relation to the current view?

推荐答案

在iOS 3.2中,有一种新的方法来实现这种效果:

As of iOS 3.2 there's a new way to achieve this effect:

code> UITextFields 和 UITextViews 有一个 inputAccessoryView 属性,

UITextFields and UITextViews have an inputAccessoryView property, which you can set to any view, that is automatically displayed above and animated with the keyboard.

请注意,您使用的视图不应该在其他地方的视图层次结构中,也不应该添加它对某些超级视图,这是为你做的。

Note that the view you use should neither be in the view hierarchy elsewhere, nor should you add it to some superview, this is done for you.

这篇关于以编程方式将iPhone键盘顶部的工具栏对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆