Recently doing cceditbox, found that after the click, the text is not suitable for
Compare today, so solve this problem
The function to find the response when Cceditbox clicked is Cceditboximplios::openkeyboard
We can see what this function says:
-(void) Openkeyboard
{
[[Eaglview sharedeglview] addsubview: Textfield_]; Add as SubView
[textfield_ Becomefirstresponder];
}
I did not deal with the textfield_ at all, so I took care of the textfield_.
Because of the Objective-c class properties are not familiar with, so asked a degree Niang, this is not the way!
So think, textfield_ must initialize, so in Cceditboximplios this source file, found the following code
-(ID) initWithFrame: (cgrect) Framerect editbox: (void*) editbox{self = [super init]; Do {if (self = = nil) break; Editstate_ = NO; Self.textfield = [[[Customuitextfield alloc] initwithframe:framerect] autorelease]; Initializes a frame if (!textfield_) break; [Textfield_ Settextcolor:[uicolor Whitecolor]; Textfield_.font = [Uifont SYSTEMFONTOFSIZE:FRAMERECT.SIZE.HEIGHT*2/3]; Initialize fonttextfield_.contentverticalalignment = Uicontrolcontentverticalalignmentcenter; Textfield_.backgroundcolor = [Uicolor Clearcolor]; Textfield_.borderstyle = Uitextborderstylenone; Textfield_.delegate = self; Textfield_.hidden = True;textfield_.returnkeytype = Uireturnkeydefault; [Textfield_ addtarget:self Action: @selector (textChanged) forcontrolevents:uicontroleventeditingchanged]; Self.editbox = EditBox; return self; }while (0); return nil;}
The following three lines of code are referenced:
Self.textfield = [[[Customuitextfield alloc] initwithframe:framerect] autorelease]; if (!textfield_) break; [Textfield_ Settextcolor:[uicolor Whitecolor];
Added the following code
-(void ) openkeyboard{ /* ****** * * * * Add by Author:zero * * * Description:cceditbox iOS adaptation issues */ CGFloat scale = [[Eaglview Sharedeglview] contentscalefactor]; CGRect rect = [Textfield_ frame]; Textfield_.font = [Uifont systemfontofsize:[textfield_ frame].size.height * scale* 2 /]; [Textfield_ Setframe:cgrectmake (rect.origin.x, RECT.ORIGIN.Y, rect.size.width * scale, Rect.size.height * scale)]; [[Eaglview Sharedeglview] addsubview:textfield_]; [Textfield_ Becomefirstresponder];}
Finally get the perfect result!
COCOS2DX 2.2.5 Cceditbox IOS adaptation issues