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

时间:2010-10-16 00:53:08

标签: iphone ios camera uiimagepickercontroller

基本上,如果用户不必滚动到他们的相机胶卷的最底部来获取他们最近的照片,我正在努力的应用程序将会减少很多痛苦,我希望最新的照片在顶部,不会这还有道理吗?不知道为什么苹果会这样设计,或者我只是没有意识到什么。

由于

缺口

4 个答案:

答案 0 :(得分:9)

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

imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

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

答案 1 :(得分:8)

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

但与此同时,这个黑客对我有用 - 我正在显示选择器,在视图层次结构中搜索滚动视图,并将其滚动到最后,或多或少。它需要动画,因为当视图已经加载时会发生这种情况 - 但它仍然比用户必须滚动浏览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];
        }
}];

答案 2 :(得分:4)

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

答案 3 :(得分:0)

您可以在arry中使用ALAsset获取图像,然后可以根据需要对其进行排序,并在表视图或collectionview中使用以构建您自己的自定义相册