ios - How to change UITableView content insets only if keyboard covers view? -


i have view controller contains tableview. reuse view controller in multiple places in app, inside of split view controller , within popover on ipad.

i added observers listen keyboard showing/hiding, , change content insets based on keyboard height. works whenever view controller full screen height, doesn't work in popover, popover resizes , tableview not covered keyboard, leaving me bunch of empty space.

is there solution this? how can change content insets if keyboard covers view?

you need find how of table view keyboard cover, , set inset much.

/* keyboard rect (which screen coordinates) in tableview coordinates */ cgrect endframescreen = [[note.userinfo objectforkey:uikeyboardframeenduserinfokey] cgrectvalue]; cgrect endframewindow = [tableview.window convertrect:endframescreen fromwindow:nil]; cgrect endframeview = [tableview convertrect:endframewindow fromview:nil];  if (!cgrectintersectsrect(tableview.bounds, endframeview)) {     /* keyboard not cover our tableview; nothing */     return; }  /* how need inset */ cgfloat bottominset = cgrectgetmaxy(tableview.bounds) - endframeview.origin.y; 

if using ios8+ only, 2 convertrect steps can changed single 1 convertrect:fromcoordinatespace:[[uiscreen mainscreen] coordinatespace]


Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -