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);
then here's last cell
then tap last text field in view , cell align top of keyboard have use code
[self.tableview setcontentinset:uiedgeinsetszero];
now once dismiss keyboard first cell looks this
and last cell looks this
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
Post a Comment