objective c - UITableView contentInset issues after UIkeyboard disappears from last text field -


i have table view , once uikeyboard dismisses last text field return key table view's contentinsets seem sorts of misplaced.

here table view cells align correctly piece of code

self.edgesforextendedlayout = uirectedgeall; self.tableview.contentinset = uiedgeinsetsmake(0.0, 0.0, cgrectgetheight(self.navigationcontroller.toolbar.frame) + 5.0, 0); 

first cell showing correct alignment

then here's last cell

last cell showing correct alignment

then tap last text field in view , cell align top of keyboard have use code

[self.tableview setcontentinset:uiedgeinsetszero]; 

setting contentinset defaults

now once dismiss keyboard first cell looks this

first cell bad alignment

and last cell looks this

last cell bad alignment

if add code when keyboard gets dismissed first cell looks first image makes last cell worse brings bottom of view half of fifth cell (there ten cells altogether). if i'd appreciate it. thanks.

[self.tableview setcontentinset:uiedgeinsetsmake(self.navigationcontroller.navigationbar.bounds.size.height + [[uiapplication sharedapplication] statusbarframe].size.height, 0.0, 0.0, 0.0)]; 

so figured out getting height of keyboard , toolbar , updating contentinset within custom method created.

[self.tableview setcontentinset:uiedgeinsetsmake(self.navigationcontroller.navigationbar.bounds.size.height + [uiapplication sharedapplication].statusbarframe.size.height, 0.0, keyboardheight + 5.0, 0.0)]; 

just in case finds useful set notification in viewdidload

[[nsnotificationcenter defaultcenter] addobserver:self                                          selector:@selector(getkeyboardheight:)                                              name:uikeyboarddidshownotification                                            object:nil]; 

then in getkeyboardheight method

keyboardheight = [[[notification userinfo] objectforkey:uikeyboardframebeginuserinfokey] cgrectvalue].size.height; keyboardheight += self.navigationcontroller.toolbar.frame.size.height; 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -