gpt4 book ai didi

crash - (cocos2d-x for iOS) UITextField 在输入时有时会崩溃

转载 作者:行者123 更新时间:2023-12-03 16:14:59 84 4
gpt4 key购买 nike

我在 cocos2d-x 项目中添加了 UITextField。但是当输入时,应用程序有时会崩溃。
请给我一些帮助,谢谢。
这是我的代码

   m_textField = [[UITextField alloc] initWithFrame:CGRectMake(TEXT_FIELD_POSX, TEXT_FIELD_POSY, TEXT_FIELD_WIDTH, TEXT_FILED_HEIGHT)];
m_textField.tag = CHAT_TEXT_TAG;
m_textField.delegate = (AppController *)clientApp.delegate;
[m_textField setBackgroundColor:[UIColor clearColor]];
[m_textField setTextColor:[UIColor blackColor]];
[m_textField setFont:[UIFont fontWithName:@"Helvetica" size:14]];
m_textField.returnKeyType = UIReturnKeySend;
m_textField.enablesReturnKeyAutomatically = YES;

[[EAGLView sharedEGLView] addSubview:m_textField];

和崩溃线程`0
CoreGraphics 0x31e09fcc CGFontStrikeRelease + 71
1
CoreGraphics 0x31e09f0b CGFontCacheUnlockStrike + 230
2
CoreGraphics 0x31e09a89 CGGlyphLockUnlock + 52
3
libRIP.A.dylib 0x34604acd ripc_DrawGlyphs + 1888
4
CoreGraphics 0x31e05361 CGContextDelegateDrawGlyphs + 44
5
CoreGraphics 0x31ee530d draw_glyphs + 396
6
CoreGraphics 0x31e05109 CGContextShowGlyphsWithAdvances + 380
7
WebCore 0x3664552b _ZN7WebCoreL22showGlyphsWithAdvancesERKNS_10FloatPointEPKNS_14SimpleFontDataEP9CGContextPKtPK6CGSizem + 1918
8
WebCore 0x36644c8f _ZNK7WebCore4Font10drawGlyphsEPNS_15GraphicsContextEPKNS_14SimpleFontDataERKNS_11GlyphBufferEiiRKNS_10FloatPointEb + 1078
9
WebCore 0x36644525 _ZNK7WebCore4Font14drawSimpleTextEPNS_15GraphicsContextERKNS_7TextRunERKNS_10FloatPointEii + 348
10
WebCore 0x366443a3 _ZNK7WebCore4Font8drawTextEPNS_15GraphicsContextERKNS_7TextRunERKNS_10FloatPointEii + 134
11
WebKit 0x34fd86ef _ZL11drawAtPointPKtiRKN7WebCore10FloatPointERKNS1_4FontEPNS1_15GraphicsContextEbPNS1_10BidiStatusEi + 210
12
WebKit 0x34fda56b -[NSString(WebStringDrawing) __web_drawInRect:withFont:ellipsis:alignment:letterSpacing:lineSpacing:includeEmoji:truncationRect:measureOnly:renderedStringOut:drawUnderline:] + 3690
13
WebKit 0x34f52187 -[NSString(WebStringDrawing) __web_drawInRect:withFont:ellipsis:alignment:letterSpacing:lineSpacing:includeEmoji:truncationRect:measureOnly:renderedStringOut:] + 114`

最佳答案

您应该像这样实现您的委托(delegate)方法:

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
cocos2d::CCEGLView* pglview = cocos2d::CCDirector::sharedDirector()->getOpenGLView();
if(pglview)
{
pglview->setIMEKeyboardState(false);
}
return YES;
}

希望它会有所帮助:)。

关于crash - (cocos2d-x for iOS) UITextField 在输入时有时会崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13656605/

84 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com