Programmatically force a UIScrollView to stop scrolling, for sharing a table view with multiple data sources

前端 未结 10 968
醉话见心
醉话见心 2020-12-08 03:04

I have a UITableView whose data source and delegate are switched between a couple of custom data source objects when the user touches a segmented control (think \"Top Paid\"

10条回答
  •  失恋的感觉
    2020-12-08 03:52

    Just found this looking for a way to stop my UIScrollView - I needed to move some subviews around, but this wound't look right if the user had flicked the screen and it was still decelerating.

    Anyway - scrollRectToVisible didn't work for me (maybe because I'm not using a table view??) but this worked perfectly:

    [mainScrollView setContentOffset:CGPointMake(mainScrollView.contentOffset.x, mainScrollView.contentOffset.y) animated:NO];
    

    I can then do the subview stuff without worrying!

提交回复
热议问题