UIImagepickercontroller:是否可以更改相机胶卷中图像的排序顺序?

nic*_*ude 8 iphone camera uiimagepickercontroller ios

基本上,应用IM工作的,如果用户没有滚动到他们的相机胶卷的最底部得到他们最近的照片,我想在顶部最近的,不会这将是一个痛苦的少了很多反正有意义吗?不知道为什么苹果这样设计,或者我只是没有意识到什么.

谢谢

缺口

Min*_*sai 9

如果您不介意添加从相册列表中选择相机胶卷的额外步骤,您可以尝试将sourceType从SavedPhotoAlbums更改为PhotoLibrary:

imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
Run Code Online (Sandbox Code Playgroud)

选择所需的相册后,下一个照片选择视图将在底部显示最新的图像.


n13*_*n13 8

这让我很烦恼 - 我很接近使用AssetsLibrary实现我自己的自定义图像选择器.

但与此同时,这个hack对我有用 - 我正在显示选择器,在视图层次结构中搜索滚动视图,并将其滚动到最后,或多或少.它需要动画,因为当视图已经加载时会发生这种情况 - 但它仍然比用户必须滚动浏览5,000张照片直到它们到达最新的照片更好.

    [self presentViewController:self.imagePickerController animated:YES completion:^() {
        // scroll to the end - hack
        UIView *imagePickerView = imagePickerController.view;

        UIView *view = [imagePickerView hitTest:CGPointMake(5,5) withEvent:nil];
        while (![view isKindOfClass:[UIScrollView class]] && view != nil) {
        // note: in iOS 5, the hit test view is already the scroll view. I don't want to rely on that though, who knows
        // what Apple might do with the ImagePickerController view structure. Searching backwards from the hit view
        // should always work though.
        //NSLog(@"passing %@", view);
            view = [view superview];
        }

        if ([view isKindOfClass:[UIScrollView class]]) {
            //NSLog(@"got a scroller!");
            UIScrollView *scrollView = (UIScrollView *) view;
            // check what it is scrolled to - this is the location of the initial display - very important as the image picker
            // actually slides under the navigation bar, but if there's only a few images we don't want this to happen.
            // The initial location is determined by status bar height and nav bar height - just get it from the picker
            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];
        }
}];
Run Code Online (Sandbox Code Playgroud)


Ole*_*ann 4

无法以这种方式自定义 UIImagePickerController,但从 iOS 4.0 开始,您基本上可以使用AssetsLibrary 框架以任何您喜欢的方式构建自己的图像选择器。