1, first need to add the previous ScrollView in the controller's view, and follow the uitextfielddelegate agent, and set the text box itself agent
2. Add gesture Monitoring
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initwithtarget:self action: @selector (Taptouch:)]; [Self.scrollerview Addgesturerecognizer:tap];
-(void) Taptouch: (uigesturerecognizer*) gesture{ [Self.view Endediting:yes]; [Self.username Resignfirstresponder]; [Self.password Resignfirstresponder]; [Self.checkpassword Resignfirstresponder]; [Self.phonenumber Resignfirstresponder]; [Self textfielddidbeginediting:0];}
3, set the appropriate code in the proxy method
-(void) textfielddidbeginediting: (Uitextfield *) textfield{ cgrect rect = self.scrollerView.frame; [UIView Beginanimations:nil context:null]; [UIView setanimationduration:0.3]; if (TextField = = Self.username) { rect.origin.y = 0; } else if (TextField = = Self.password) { rect.origin.y = -50; } else if (TextField = = Self.checkpassword) { rect.origin.y = -80; } else if (TextField = = Self.phonenumber) { rect.origin.y = -100; } else { rect.origin.y = 0; } Self.scrollerView.frame = rect; [UIView commitanimations]; }
Get
Simple way to solve the keyboard occlusion text box