UICollectionView automatically scroll to bottom when screen loads

后端 未结 9 2094
Happy的楠姐
Happy的楠姐 2021-02-05 02:44

I\'m trying to figure out how to scroll all the way to the bottom of a UICollectionView when the screen first loads. I\'m able to scroll to the bottom when the status bar is tou

9条回答
  •  醉话见心
    2021-02-05 02:50

    For me, i found next solution:

    call reloadData in CollectionView, and make dcg on main to scroll.

     __weak typeof(self) wSelf = self;
    
     [wSelf.cv reloadData];
     dispatch_async(dispatch_get_main_queue(), ^{
     NSLog(@"HeightGCD:%@", @(wSelf.cv.contentSize.height));
     [wSelf.cv scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:50 inSection:0] atScrollPosition:UICollectionViewScrollPositionBottom animated:YES];
     });
    

提交回复
热议问题