0

I use the following code to present an NavigationController

GridMenuViewController* vc = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"GridMenuViewControllerID"];
GridMenuNavigationController *nav = [[GridMenuNavigationController alloc] initWithRootViewController:vc];
vc.sheetPresentationController.prefersScrollingExpandsWhenScrolledToEdge = NO;
nav.modalPresentationStyle = UIModalPresentationPageSheet;
if (@available(iOS 16.0, *)) {
    if (nav.sheetPresentationController) {
        id detent = [UISheetPresentationControllerDetent customDetentWithIdentifier:UISheetPresentationControllerDetentIdentifierLarge resolver:^CGFloat(id<UISheetPresentationControllerDetentResolutionContext>  _Nonnull context) {
            return [[UIScreen mainScreen] bounds].size.height * 0.6;
        }];
        nav.sheetPresentationController.detents = @[detent];
        nav.sheetPresentationController.prefersGrabberVisible = YES;
    }
}
nav.sheetPresentationController.prefersScrollingExpandsWhenScrolledToEdge = NO;
[self presentViewController:nav animated:YES completion:nil];

I woluld like to disable the bounces when scroll up the present view, how can I do that?

Support video https://www.youtube.com/watch?v=P53ZPxzdWCU

I tried so many code like

if (@available(iOS 11.0, *)) {
    self.collectionView.contentInsetAdjustmentBehavior = 2;
} else {
    self.collectionView.automaticallyAdjustsScrollIndicatorInsets = NO;
}
self.collectionView.verticalScrollIndicatorInsets = UIEdgeInsetsMake(0, 0, self.view.safeAreaInsets.bottom, 0);
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    [scrollView setContentOffset: CGPointMake(scrollView.contentOffset.x, 0)];
}

I expecting there no any bounces behavior when scroll up.

Satoshi
  • 13
  • 9
  • Maybe https://developer.apple.com/documentation/uikit/uiscrollview/1619383-alwaysbouncevertical ? – Larme Jul 16 '23 at 20:51
  • Thanks for reply, but where I can find the UIScrollView? ViewController ,UINavigationController and presentedViewController also not find ScrollView inside – Satoshi Jul 18 '23 at 04:27
  • `UICollectionView` inherits from `UIScrollView` – Larme Jul 18 '23 at 07:30

0 Answers0