有没有在iOS上从屏幕上删除键盘的选项?在这种情况下,我使用Tabris(http://developer.eclipsesource.com/tabris/)和Java。在iOS中使用Tabris隐藏键盘
我的问题是,我使用两个文本框输入用户/密码组合。填充这些文本框并按下一个按钮以继续iOS中的键盘始终显示,但我希望键盘不再出现。只有在我点击某处后,键盘才会消失。
有没有在iOS上从屏幕上删除键盘的选项?在这种情况下,我使用Tabris(http://developer.eclipsesource.com/tabris/)和Java。在iOS中使用Tabris隐藏键盘
我的问题是,我使用两个文本框输入用户/密码组合。填充这些文本框并按下一个按钮以继续iOS中的键盘始终显示,但我希望键盘不再出现。只有在我点击某处后,键盘才会消失。
在Tabris,你可以通过设置它使用键盘(如org.eclipse.swt.widgets.Text)上控制对焦“打开”键盘编程。 要隐藏键盘,只需将焦点设置为不需要键盘的控件,就像Textfield的父组合一样。
在你的情况下,我会将al行添加到Button的SelectionListener中,以便将Focus设置为Textfields的Parent,然后启动登录过程。
下面是一些代码,发挥和理解对焦机构:
public class FocusTest implements EntryPoint {
public int createUI() {
Display display = new Display();
Shell shell = new Shell(display, SWT.NO_TRIM);
shell.setMaximized(true);
GridLayoutFactory.fillDefaults().applyTo(shell);
createContent(shell);
shell.open();
//while (!shell.isDisposed()) {
// if (!display.readAndDispatch()) {
// display.sleep();
// }
//}
return 0;
}
private void createContent(final Composite parent) {
Button buttonSingleText = new Button(parent, SWT.PUSH);
buttonSingleText.setText("Focus on SingleText");
GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(buttonSingleText);
Button buttonMultiText = new Button(parent, SWT.PUSH);
buttonMultiText.setText("Focus on MultiText");
GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(buttonMultiText);
Button buttonNoFocus = new Button(parent, SWT.PUSH);
buttonNoFocus.setText("Loose Focus");
GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(buttonNoFocus);
final Text singleText = new Text(parent, SWT.SINGLE);
GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(singleText);
final Text multiText = new Text(parent, SWT.MULTI);
GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(multiText);
buttonSingleText.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
singleText.setFocus();
}
});
buttonMultiText.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
multiText.setFocus();
}
});
buttonNoFocus.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
parent.setFocus();
}
});
}
}
您是否设置了UITextField委托并在其中添加以下方法?
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return YES;
}
我试过的例子,但松动的焦点的按钮无法正常工作。我在iPhone模拟器中尝试了这一点,并且键盘不会隐藏。 – user1534567