How to navigate through textfields (Next / Done Buttons)
来源:互联网 发布:烤箱daogrs 知乎 编辑:程序博客网 时间:2024/05/29 14:23
how can i navigate through all my text fields with the "Next" Button on the iPhone Keyboard.
The last text field should close the Keyboard.
I setup in the IB the Buttons (Next / Done) but now im stuck.
I implemented the textFieldShouldReturn action but now the Next and Done Buttons close the Keyboard.
Thanks for your help!
我怎么才能通过点击iPhone键盘上的“NEXT”按钮来导航,
最后一个textField应该是要关闭键盘
我在ib里面已经设置了按钮的next/done
我实现了textFieldShouldReturn方法, 但是next/done按钮没有关闭键盘
In Cocoa for Mac OS X you have the next responder chain, where you can ask the text field what control should have focus next. This is what makes tabbing between text fields work. But since iPhone do not have a key board, only touch, this concept has not survived the transition to Cocoa Touch.
This can be easily done anyway, with two assumptions:
- All "tabbable"
UITextField
s are on the same parent view. - Their "tab-order" is defined by the tag property.
Assuming this you can override textFieldShouldReturn: as this:
在mac os里面,有下一个响应者链,你可以看textField的焦点是不是“next”
-(BOOL)textFieldShouldReturn:(UITextField*)textField;
{
NSInteger nextTag = textField.tag + 1;
// Try to find next responder
UIResponder* nextResponder = [textField.superview viewWithTag:nextTag];
if (nextResponder) {
// Found next responder, so set it.
[nextResponder becomeFirstResponder];
} else {
// Not found, so remove keyboard.
[textField resignFirstResponder];
}
return NO; // We do not want UITextField to insert line-breaks.
}
- How to navigate through textfields (Next / Done Buttons)
- How to change text of CBA buttons?
- How to change text of CBA buttons?
- How to change text of CBA buttons?
- How to change text of CBA buttons?
- How to change text of CBA buttons?
- How to change text of CBA buttons?
- How to change text of CBA buttons?
- How to change text of CBA buttons?
- How to change text of CBA buttons?
- How to make sexy buttons with CSS
- How to navigate every url to www.csdn.net
- How to Navigate, Group, Sort and Filter Data in WPF
- textFields
- How to use ADB through lan
- How To Create a Modeless CPropertySheet with Standard Buttons
- How to add buttons (Home, Back, Menu) on Android statusBar
- How To Create Buttons in Cocos2D: Simple, Radio, and Toggle
- HDU2046 骨牌铺方格
- 使用C/S的方式进行单点登陆
- document.getElementById(...) is null
- sap adapter 配置message server
- 想起自己学C时的一个笑话
- How to navigate through textfields (Next / Done Buttons)
- sqlserver char,nchar,varchar,nvarchar区别比较
- C++_动态存储空间的分配和释放
- static_cast、dynamic_cast、reinterpret_cast、和const_cast
- mysql使用数据库连接池
- objective-c 使用文件(一)
- 完整的VS2010 快捷键大全
- 深入了解VC++编译器
- 令人迷惑的String类