Method 1
Textfield.clearbuttonmode = uitextfieldviewmodewhileediting;
Method 2
Inheritance Uitextfield override method
-(CGRect) Textrectforbounds: (cgrect) bounds
{return
cgrectinset (bounds, 2, 1);
}
-(CGRect) Editingrectforbounds: (cgrect) bounds
{return
cgrectinset (bounds, 2, 1);
}
Method 3
If the text size is not high, the display area is large enough, Uitextfield can be displayed normally.
//When Uitextfield cannot fully display Chinese characters, it becomes scrollable, the text is below the centerline, and when you click the Delete button, it looks downward.
//Using the Layoutsubviews method of the NSLog output Uitextfield, the Uitexteditor Contentoffset is shown to have an offset.
//So rewrite the Layoutsuviews method to reset the contentoffset.y of the uitexteditor after [Super Layoutsubview].
-(void) Layoutsubviews
{
[super layoutsubviews];
For (Uiscrollview *view in self.subviews)
{
if ([View Iskindofclass:[uiscrollview class]])
{
Cgpoint offset = View.contentoffset;
if (offset.y!= 0)
{
offset.y = 0;
View.contentoffset = offset;
}
break;
}
}
Refer to the following three posts
Post 1–stackoverflow
Post 2–stackoverflow
Post 3–cocoachina