ios - contentOffset is reset on ScrollView header when vertical scrolling in UITableView -


im making use of code align load of truckdayscrollviews (subclass of uiscrollview) horizontally in uitableview, sudaysfortruckview custom uilabel

-(void)scrollviewdidscroll:(uiscrollview *)scrollview {      if ([scrollview iskindofclass:[sudaysfortruckview class]]) {         cgpoint offset=cgpointmake(scrollview.contentoffset.x, 0);         (truckviewcell *cell in self.tableview.visiblecells) {             cell.truckdayscrollview.contentoffset=offset;          }         self.headerview.contentoffset=offset;         self.scrollviewposition=offset;     }     else{         nslog(@"table view scrolling vertically: %f,%f",self.scrollviewposition.x,self.scrollviewposition.y);         self.headerview.contentoffset=self.scrollviewposition;     } } 

the idea being, if class of scrolling scroll view part of cell (scrolling horizontally) update scrollviews, including header. works great.

although when tableview scrolls vertically, content offset in header scroll view reset 0,0.

why this, , there way fix it. have tried putting line

    self.headerview.contentoffset=self.scrollviewposition; 

in many places cellforrow, getter self.headerview,etc. no avail.

the first picture shows horizontal scrolling , how header aligned, second picture shows happens on first bit of vertical scrolling, headers jump out of alignment immediately.

during horizontal scrolling, aligned.

during vertical scrolling, poop.

i ended overriding drawrect: current content offset of scrollviews before vertical scrolling. , needed little bit stop views having black background.

- (void)drawrect:(cgrect)rect {      [super drawrect:rect];     cgcontextref ctx = uigraphicsgetcurrentcontext();     cgfloat white[] = {1, 1, 1, 1};     cgcontextsetfillcolor(ctx, white);     cgcontextaddrect(ctx, rect);     cgcontextfillpath(ctx);     self.contentoffset=[self.scrollviewmaster scrollviewposition]; } 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -