[IOS] Uitableviewcontroller Complete Retract keyboard operation

Source: Internet
Author: User

The Uitableviewcontroller itself enables keyboard adaptation (the control focus in the cell is moved above the keyboard

Think about the following when you do a keyboard retraction

1. TableView Add Click event

Result: Click events and TableView didselect conflict, resulting in didselect failure

2, ScrollView agent scroll back keyboard

Results: The goal can be achieved, but when the click TextField, the keyboard will appear after the direct recovery. The reason is that the first adaptation → Call ScrollView proxy.

Finally, the following scenario is used



    <span style= "font-family:arial, Helvetica, Sans-serif;" >_SUREBTN = [UIButton buttonwithtype:uibuttontypecustom];</span>    _surebtn.frame = CGRectMake ( SELF.VIEW.SIZE.WIDTH-60, 5, ();    _surebtn.backgroundcolor = [Uicolor colorwithred:0.150 green:0.662 blue:0.915 alpha:1.000];    _surebtn.titlelabel.font = [Uifont systemfontofsize:15];    _surebtn.layer.cornerradius = 5.0;    [_surebtn settitle:@ "OK" forstate:uicontrolstatenormal];    [_surebtn addtarget:self Action: @selector (Changeremarks) forcontrolevents:uicontroleventtouchupinside];    _view=[[uiview Alloc] Initwithframe:cgrectmake (0, 0, self.view.frame.size.width, +)];    _view.backgroundcolor=[uicolor Whitecolor];    UIView *line = [[UIView alloc] Initwithframe:cgrectmake (0, 0, Self.view.frame.size.width, 0.5)];    Line.backgroundcolor = [Uicolor blackcolor];    [_view Addsubview:line];    [_view ADDSUBVIEW:_SUREBTN];


When used, the following treatment is textfield into the

_begoodatfield.inputaccessoryview = _view;

If it's a text box in cell TableView

You need to define a temporary textfield.

When using the

_xuexiaofield=cellmenu.celltext; _xuexiaofield.inputaccessoryview = _view;//<span style= "font-family:arial, Helvetica, Sans-serif;" >cellmenu the name of the custom cell </span>
Attach the OK button method
-(void) changeremarks{    [_nicktextfield Resignfirstresponder];    [_xuexiaofield Resignfirstresponder];    [_begoodatfield Resignfirstresponder];    [_bumenfield Resignfirstresponder];}



Https://github.com/KKKKaras/SureBtnDemo


[IOS] Uitableviewcontroller Complete Retract keyboard operation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.