2013-03-26 74 views
2

在我的應用程序中,我需要從照片庫中選擇圖片,我有數百張照片。這個問題是由相機捕獲的最新照片,保存在照片庫的底部,因此,我必須全面向下滾動以選擇由我拍攝的最新照片。有什麼辦法可以將ImagePickerViewController的視圖滾動到底部,還是可以將最新的圖片存儲在頂部?我們可以滾動iPhone照片庫到底部編程

回答

4
[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]; 
       } 
     }];