我们正在将 libgdx 游戏移植到 ios。
我创建一个 UITextField 并设置委托,这里是代码:
this.textField.setDelegate(new Delegate(textField));
public static class Delegate extends UITextFieldDelegate.Adapter
{
private UITextField mTextField;
public Delegate(UITextField textField)
{
this.mTextField = textField;
}
@Override
public void didBeginEditing(UITextField textField) {
// TODO Auto-generated method stub
Gdx.app.debug(TAG, "didBeginEditing");
}
@Override
public void didEndEditing(UITextField textField) {
// TODO Auto-generated method stub
Gdx.app.debug(TAG, "didEndEditing");
}
@Override
public boolean shouldBeginEditing(UITextField textField) {
// TODO Auto-generated method stub
Gdx.app.debug(TAG, "shouldBeginEditing");
return true;
}
@Override
public boolean shouldChangeCharacters(UITextField textField,
NSRange range, String string) {
// TODO Auto-generated method stub
Gdx.app.debug(TAG, "shouldChangeCharacters");
return true;
}
@Override
public boolean shouldClear(UITextField textField) {
// TODO Auto-generated method stub
Gdx.app.debug(TAG, "shouldClear");
return true;
}
@Override
public boolean shouldEndEditing(UITextField textField) {
// TODO Auto-generated method stub
Gdx.app.debug(TAG, "shouldEndEditing");
return true;
}
@Override
public boolean shouldReturn(UITextField textField) {
// TODO Auto-generated method stub
if(this.mTextField == textField)
{
textField.resignFirstResponder();
}
Gdx.app.debug(TAG, "shouldReturn");
return true;
}
}
在 ios 模拟器上,当我单击文本字段时,应用程序将崩溃,并且控制台上没有错误消息。如何解决?任何信息将不胜感激!提前致谢!!