#pragma mark-uikeyboard obscure problem-(void) Handlekeyboardstuff {[[Nsnotificationcenter Defaultcenter] AddObs Erver:self selector: @selector (keyboardwillshow:) name:uikeyboardwillshownotification Object:nil]; [[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (keyboardwillhide:) Name: Uikeyboardwillhidenotification Object:nil]; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initwithtarget:self Action: @selector (Tapscrollview:)]; [_scrollview Addgesturerecognizer:tap];} -(void) Keyboardwillshow: (nsnotification *) notification {[Self adjustinsetforkeyboardshow:yes notification:notific Ation];} -(void) Keyboardwillhide: (nsnotification *) notification {[Self adjustinsetforkeyboardshow:no notification:notifica tion];} -(void) Tapscrollview: (ID) Sender {[_scrollview endediting:yes];} -(void) Adjustinsetforkeyboardshow: (BOOL) Show Notification: (nsnotification *) Notification {Nsdictionary *userinfo = n Otification.userInfo; CGRect Keyboardframe = ((Nsvalue *) Userinfo[uikeyboardframebeginuserinfokey]). Cgrectvalue; CGFloat adjustmentheight = (Cgrectgetheight (keyboardframe) + 20.0) * (Show 1:-1); Uiedgeinsets scrollinsets = _scrollview.contentinset; Scrollinsets.bottom + = Adjustmentheight; _scrollview.contentinset = scrollinsets; Uiedgeinsets indicatorinsets = _scrollview.scrollindicatorinsets; Indicatorinsets.bottom + = Adjustmentheight; _scrollview.scrollindicatorinsets = indicatorinsets; }-(void) dealloc {[[Nsnotificationcenter defaultcenter] removeobserver:self];}
Add the above code and finally add it in the Viewdidload method:
[Self handlekeyboardstuff];
Uiscrollview Keyboard occlusion problem