IOS Keyboard Processing (change keyboard for completion key), Uitextfield keyboard display hidden, popup, rebound

Source: Internet
Author: User

Many times when using Uitextfield, handling the keyboard is a tricky issue. Question one: How do I hide my keyboard? Scenario 1. Change the bottom right corner of the keyboard line break (enter) key is the completion key, after the implementation of proxy method keyboard auto Rebound
Keyboardcontroll.gif
Uitextfield *textfield = [[Uitextfield Alloc]initwithframe:CGRectMake (100,300,200,40)]; [Self.view Addsubview:textfield];Textfield.delegate = self;Textfield.returnkeytype =uireturnkeydone;//changes to the finish key, if you import theYytext Frame then the original is replaced and changed to Returnkeytype =uikeyboardtypetwitter;//implementationUitextfield Proxy Method-(BOOL) Textfieldshouldreturn: (uitextfield *) TextField {[TextField resignfirstresponder];//cancel First responder return 

Of course, Sogou Input method is the function of the hidden keyboard, but you can not guarantee that each user is equipped with Sogou input method, this scheme will also change the lower right corner of the Sogou keyboard button for the completion of the key

Scenario 2. Click the TextField outside the keyboard to rebound
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {    [self.view endEditing:YES];}

If the TextField on the TableView can also implement the following TableView proxy method

-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{    [self.view endEditing:YES];}
Issue two: Keyboard and keyboard masking input box problems

Solution Solutions

#pragma mark - textFieldDelegate(别忘了遵守协议设置代理)- (void)textFieldDidBeginEditing:(UITextField *)textField {   self.view.y = self.view.y - 216; //216是输入框在最底部时view移动的距离,具体移动多少距离,需要根据实际情况而定}- (void)textFieldDidEndEditing:(UITextField *)textField { self.view.y = self.view.y + 216;}

 

IOS Keyboard Processing (change keyboard for completion key), Uitextfield keyboard display hidden, popup, rebound

Related Article

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.