【问题标题】:Can we scroll iPhone Photo Library to Bottom Programmatically我们可以以编程方式将 iPhone 照片库滚动到底部吗
【发布时间】:2013-03-26 10:32:22
【问题描述】:

在我的应用程序中,我需要从照片库中选择图像,其中有数百张照片。问题是相机拍摄的最新照片,保存在照片库的底部,因此,我必须向下滚动以选择我拍摄的最新照片。有什么方法可以将 ImagePickerViewController 的视图滚动到底部,或者我可以将最新的图片存储在顶部吗?

【问题讨论】:

    标签: iphone ios scroll uiimagepickercontroller photo-gallery


    【解决方案1】:
    [self presentViewController:imagePickerController animated:YES completion:^()
            {
                   UIView *imagePickerView = imagePickerController.view;
                   UIView *view = [imagePickerView hitTest:CGPointMake(5,5) withEvent:nil];
                   while (![view isKindOfClass:[UIScrollView class]] && view != nil)
                   {
                        view = [view superview];
                   }
                   if ([view isKindOfClass:[UIScrollView class]])
                   {
                       UIScrollView *scrollView = (UIScrollView *) view;
                       CGPoint contentOffset = scrollView.contentOffset;
                       CGFloat y = MAX(contentOffset.y, [scrollView contentSize].height-scrollView.frame.size.height);
                       CGPoint bottomOffset = CGPointMake(0, y);
                       [scrollView setContentOffset:bottomOffset animated:YES];
                   }
           }];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-10-31
      • 2018-11-22
      • 2016-01-30
      • 2011-12-22
      • 2015-07-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多