ios - How create NSLayoutConstraint when scrolling UITableView -


i have uitableview on singleview. table view have constraint left 0, right 0, bottom 0, top 520. need change top 520 0 when scrolling up, , when scrolling bottom return 520. how can make it. how change nslayoutconstraint scroll in -

- (void)scrollviewdidscroll:(uiscrollview *)scrollview 

i trying implement so-but failed

 - (void)scrollviewdidscroll:(uiscrollview *)scrollview{      if (scrollview.tag == 1){          if (scrollview.contentoffset.y < pointnow.y) {              self.heightlogtabtableview.constant = 0;              [uiview animatewithduration:0.5f animations:^{                 [self.view layoutifneeded];             }];          }else if (scrollview.contentoffset.y > pointnow.y) {              self.heightlogtabtableview.constant = 520;             [uiview animatewithduration:0.5f animations:^{                 [self.view layoutifneeded];             }];         }     } } 

replace [self.view layoutifneeded]; in code by-- [_tableview beginupdates]; , [_tableview endupdates];. modify variable pointnow follows.

#import "viewcontroller.h"  @interface viewcontroller (uiscrollviewdelegate){  }   @end  @implementation viewcontroller cgpoint pointnow;  - (void)viewdidload{       [super viewdidload];         pointnow = cgpointmake(0, 0);  }  - (void)scrollviewdidscroll:(uiscrollview *)scrollview{            if (scrollview.contentoffset.y < pointnow.y) {              self.heightlogtabtableview.constant = 0;              [uiview animatewithduration:0.5f animations:^{                 [_tableview beginupdates];                 [_tableview endupdates];             }];          }else if (scrollview.contentoffset.y > pointnow.y) {              self.heightlogtabtableview.constant = 520;             [uiview animatewithduration:0.5f animations:^{                 [_tableview beginupdates];                 [_tableview endupdates];             }];         }     pointnow = scrollview.contentoffset;  }  @end 

Comments