UIView on top of UITableView -


i have been developing app in have uiviewcontroller, have added uitableview. want add uiview on top of tableview @ fixed position.

i tried following code, uiview scrolls along tableview:

- (void)viewdidload {     uiview *view = [[uiview alloc] initwithframe:cgrectmake(250, 100, 50, 50)];     view.backgroundcolor = [uicolor orangecolor];     [_tableview addsubview:view];     [_tableview bringsubviewtofront:view]; } 

how can prevent uiview scrolling?

well, since uitableview subclass of uiscrollview try implement "floating view". should make sure

  1. the floating view top view in hierarchy
  2. the position of floating view should updated when contentoffset changes (so visually float on top of other content when user scrolling)

you can try (assuming floatingheaderviewcenter initial center of floatingview:

- (void)scrollviewdidscroll:(uiscrollview *)scrollview {     self.floatingheaderview.center = cgpointmake(floatingheaderviewcenter.x + scrollview.contentoffset.x, floatingheaderviewcenter.y + scrollview.contentoffset.y);     [scrollview bringsubviewtofront:floatingheaderview]; } 

although you'd better have view container 2 subviews: tableview , floating view.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -