UIImagepickercontroller: is it possible to change

2020-01-31 07:46发布

Basically the app im working on would be a lot less of a pain if users didn't have to scroll to the very bottom of their camera roll to get their most recent photos, I want the most recent at the top, wouldn't this make sense anyway? Not sure why apple designed it this way, or if im just not realizing something.

Thanks

nick

4条回答
等我变得足够好
2楼-- · 2020-01-31 08:13

This annoyed me a whole lot - I am this close to implementing my own custom image picker using AssetsLibrary.

But in the meantime, this hack worked for me - I am displaying the picker, searching for the scroll view in the view hierarchy, and scrolling it to the end, more or less. It needs to be animated as this happens when the view is already loaded - but it's still better than the user having to scroll through 5,000 photos until they get to the newest ones.

    [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];
        }
}];
查看更多
Ridiculous、
3楼-- · 2020-01-31 08:15

There is no way to customize UIImagePickerController in this way, but as of iOS 4.0, you can basically build your own image picker in any way you like using the AssetsLibrary framework.

查看更多
Animai°情兽
4楼-- · 2020-01-31 08:20

If you don't mind adding an extra step of selecting the camera roll from an album list you can try changing your sourceType from SavedPhotoAlbums to PhotoLibrary:

imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

After selecting the desired album, the next photo selection view will show the most recent images at the bottom.

查看更多
Summer. ? 凉城
5楼-- · 2020-01-31 08:21

You can get images, using ALAsset in an arry, and then can sort them as you want and use in table view or collectionview to build your own custom album

查看更多
登录 后发表回答