Sfoglia il codice sorgente

1.使用UICollectionView重写iOS RA Image图像预览界面。

Pen Li 9 anni fa
parent
commit
713d205099

+ 12 - 0
RA Image/RA Image.xcodeproj/project.pbxproj

@@ -13,6 +13,8 @@
 		426E6B241EB85C2B00942BE1 /* PopModeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 426E6B231EB85C2B00942BE1 /* PopModeViewController.m */; };
 		426E6B271EB85C4200942BE1 /* ModelModeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 426E6B261EB85C4200942BE1 /* ModelModeViewController.m */; };
 		426E6B291EB8720400942BE1 /* Mode.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 426E6B281EB8720400942BE1 /* Mode.storyboard */; };
+		428566D51EF1220F0041208A /* NewPhotoPreviewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 428566D41EF1220F0041208A /* NewPhotoPreviewController.m */; };
+		428566D81EF122360041208A /* PhotoPreviewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 428566D71EF122360041208A /* PhotoPreviewCell.m */; };
 		429F25221EC9AA4200C22ABB /* TakePhotoPreviewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 429F25211EC9AA4200C22ABB /* TakePhotoPreviewController.m */; };
 		42A829C01EBC027100898B8A /* RootNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 42A829BF1EBC027100898B8A /* RootNavigationController.m */; };
 		42A829C31EBC0F8300898B8A /* ManufacturerListController.m in Sources */ = {isa = PBXBuildFile; fileRef = 42A829C21EBC0F8300898B8A /* ManufacturerListController.m */; };
@@ -80,6 +82,10 @@
 		426E6B251EB85C4200942BE1 /* ModelModeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModelModeViewController.h; sourceTree = "<group>"; };
 		426E6B261EB85C4200942BE1 /* ModelModeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ModelModeViewController.m; sourceTree = "<group>"; };
 		426E6B281EB8720400942BE1 /* Mode.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Mode.storyboard; sourceTree = "<group>"; };
+		428566D31EF1220F0041208A /* NewPhotoPreviewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewPhotoPreviewController.h; sourceTree = "<group>"; };
+		428566D41EF1220F0041208A /* NewPhotoPreviewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NewPhotoPreviewController.m; sourceTree = "<group>"; };
+		428566D61EF122360041208A /* PhotoPreviewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhotoPreviewCell.h; sourceTree = "<group>"; };
+		428566D71EF122360041208A /* PhotoPreviewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PhotoPreviewCell.m; sourceTree = "<group>"; };
 		429F25201EC9AA4200C22ABB /* TakePhotoPreviewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TakePhotoPreviewController.h; sourceTree = "<group>"; };
 		429F25211EC9AA4200C22ABB /* TakePhotoPreviewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TakePhotoPreviewController.m; sourceTree = "<group>"; };
 		42A829BE1EBC027100898B8A /* RootNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootNavigationController.h; sourceTree = "<group>"; };
@@ -280,6 +286,8 @@
 				42BC2CFE1EBAC4050016B30D /* PhotoListViewController.m */,
 				42BC2D0A1EBB00FD0016B30D /* PhotoPreviewController.h */,
 				42BC2D0B1EBB00FD0016B30D /* PhotoPreviewController.m */,
+				428566D31EF1220F0041208A /* NewPhotoPreviewController.h */,
+				428566D41EF1220F0041208A /* NewPhotoPreviewController.m */,
 				42BC2D021EBAC4950016B30D /* view */,
 			);
 			name = PhotoList;
@@ -290,6 +298,8 @@
 			children = (
 				42BC2D031EBAC4C00016B30D /* PhotoCell.h */,
 				42BC2D041EBAC4C00016B30D /* PhotoCell.m */,
+				428566D61EF122360041208A /* PhotoPreviewCell.h */,
+				428566D71EF122360041208A /* PhotoPreviewCell.m */,
 			);
 			name = view;
 			sourceTree = "<group>";
@@ -615,6 +625,7 @@
 				71114AC61EB1C73B00D2200C /* ioapi.c in Sources */,
 				42056E7E1EB989AB0010597A /* JLKeyboardListener.m in Sources */,
 				71114AF11EB2DEF900D2200C /* ScannerControllerView.m in Sources */,
+				428566D51EF1220F0041208A /* NewPhotoPreviewController.m in Sources */,
 				71114A9D1EB1BCB400D2200C /* LoginViewController.m in Sources */,
 				71114AB51EB1C5C800D2200C /* NSData+CommonCrypto.m in Sources */,
 				71114AC71EB1C73B00D2200C /* mztools.c in Sources */,
@@ -630,6 +641,7 @@
 				71114AEF1EB2DEF900D2200C /* MenuViewController.m in Sources */,
 				71114AA31EB1C40900D2200C /* RAINetwork.m in Sources */,
 				71114AC91EB1C73B00D2200C /* zip.c in Sources */,
+				428566D81EF122360041208A /* PhotoPreviewCell.m in Sources */,
 				71114AF31EB2DEF900D2200C /* SCShapeView.m in Sources */,
 				71961CB11EC00DDD002C4096 /* RAUploadManager.m in Sources */,
 				71114AF21EB2DEF900D2200C /* ScannerViewController.m in Sources */,

BIN
RA Image/RA Image.xcodeproj/project.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate


+ 2 - 4
RA Image/RA Image/BasicModeViewController.m

@@ -466,11 +466,10 @@
                             [weakself receiveImage:img];
                             NSString *md5 = [RAUtils md5WithFile:path];
                             NSMutableDictionary *photoDic = @{
-                                                              @"photo" : img,
                                                               @"check" : @(NO),
                                                               @"file"  : [path lastPathComponent],
                                                               @"md5"   : md5,
-                                                              @"path"  : path
+                                                              @"path"  : path,
                                                               }.mutableCopy;
                             [weakself.photos insertObject:photoDic atIndex:0];
                             weakself.photoCount++;
@@ -496,11 +495,10 @@
                     [self receiveImage:image];
                     NSString *md5 = [RAUtils md5WithFile:path];
                     NSMutableDictionary *photoDic = @{
-                                                      @"photo" : image,
                                                       @"check" : @(NO),
                                                       @"file"  : [path lastPathComponent],
                                                       @"md5"   : md5,
-                                                      @"path"  : path
+                                                      @"path"  : path,
                                                       }.mutableCopy;
                     [self.photos insertObject:photoDic atIndex:0];
                     self.photoCount++;

+ 17 - 0
RA Image/RA Image/NewPhotoPreviewController.h

@@ -0,0 +1,17 @@
+//
+//  NewPhotoPreviewController.h
+//  RA Image
+//
+//  Created by Jack on 2017/6/14.
+//  Copyright © 2017年 USAI. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface NewPhotoPreviewController : UIViewController
+
+@property (nonatomic,strong) NSArray *photos;
+
+@property (nonatomic,assign) NSUInteger currentIndex;
+
+@end

+ 195 - 0
RA Image/RA Image/NewPhotoPreviewController.m

@@ -0,0 +1,195 @@
+//
+//  NewPhotoPreviewController.m
+//  RA Image
+//
+//  Created by Jack on 2017/6/14.
+//  Copyright © 2017年 USAI. All rights reserved.
+//
+
+#import "NewPhotoPreviewController.h"
+#import "PhotoPreviewCell.h"
+
+@interface NewPhotoPreviewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
+
+@property (strong, nonatomic) IBOutlet UILabel *indicator;
+@property (strong, nonatomic) IBOutlet UICollectionView *previewContainer;
+
+@end
+
+@implementation NewPhotoPreviewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+//    self.automaticallyAdjustsScrollViewInsets = NO;
+//    self.navigationController.navigationBar.translucent = NO;
+//    self.edgesForExtendedLayout = UIRectEdgeNone;
+
+    UIView *v = [UIView new];
+    [self.view insertSubview:v atIndex:0];
+    
+    self.indicator.layer.cornerRadius = 20;
+    self.indicator.layer.masksToBounds = YES;
+    
+    self.previewContainer.pagingEnabled = YES;
+    NSString *offset = [NSString stringWithFormat:@"%lu / %lu",(unsigned long)self.currentIndex + 1,(unsigned long)self.photos.count];
+    self.indicator.text = offset;
+    
+    
+}
+
+- (void)viewDidLayoutSubviews {
+    [super viewDidLayoutSubviews];
+//    
+//    UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)self.previewContainer.collectionViewLayout;
+//    CGFloat w = CGRectGetWidth(self.view.frame);
+//    CGFloat h = CGRectGetHeight(self.view.frame);
+//    layout.itemSize = CGSizeMake(w,h);
+//    layout.minimumLineSpacing = 0;
+//    layout.minimumInteritemSpacing = 0;
+    
+}
+
+- (void)viewDidAppear:(BOOL)animated {
+    [super viewDidAppear:animated];
+
+    [self.previewContainer reloadData]; // 重新布局Item大小才正确
+    
+}
+
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+#pragma mark - Setter
+
+- (void)setCurrentIndex:(NSUInteger)currentIndex {
+    _currentIndex = currentIndex;
+    NSString *offset = [NSString stringWithFormat:@"%lu / %lu",(unsigned long)self.currentIndex + 1,(unsigned long)self.photos.count];
+    self.indicator.text = offset;
+}
+
+#pragma mark - FlowLayout Delegate
+
+- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
+    return collectionView.bounds.size;
+}
+
+- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
+    return 0;
+}
+
+- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
+    return 0;
+}
+
+- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
+    return UIEdgeInsetsZero;
+}
+
+- (void)collectionviewdidend
+
+#pragma mark - CollectionView Delegate
+
+- (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath {
+    PhotoPreviewCell *preCell = (PhotoPreviewCell *)cell;
+    
+    self.currentIndex = indexPath.row;
+    
+    UIScrollView *sc = preCell.scrollView;
+    sc.delegate = self;
+    sc.maximumZoomScale = 5;
+    sc.showsVerticalScrollIndicator = NO;
+    sc.showsHorizontalScrollIndicator = NO;
+    NSDictionary *item = [self.photos objectAtIndex:indexPath.row];
+    UIImage *img = [UIImage imageWithContentsOfFile:[item objectForKey:@"path"]];
+    
+    CGFloat width = CGRectGetWidth(cell.bounds);
+    CGFloat height = CGRectGetHeight(cell.bounds);
+    CGFloat w = img.size.width;
+    CGFloat h = img.size.height;
+    // 根据图片大小和ScrollView大小等比缩放,使ScrollView容得下图片
+    float factor = MAX(w / width, h / height);
+    factor = 1 / factor * 0.8;
+    
+    CGRect frame = CGRectMake((width - w * factor) * 0.5, (height - h * factor) * 0.5, w * factor, h * factor);
+    UIImageView *iv = [[UIImageView alloc] initWithImage:img];
+    iv.frame = frame;
+    iv.userInteractionEnabled = YES;
+    for (UIView *v in sc.subviews) {
+        [v removeFromSuperview];
+    }
+    [sc addSubview:iv];
+    sc.contentSize = CGSizeZero;
+    sc.contentOffset = CGPointZero;
+}
+
+- (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath {
+    PhotoPreviewCell *preCell = (PhotoPreviewCell *)cell;
+    UIScrollView *sc = preCell.scrollView;
+    for (UIView *v in sc.subviews) {
+        [v removeFromSuperview];
+    }
+    sc.zoomScale = 1;
+    sc.contentSize = CGSizeZero;
+    sc.contentOffset = CGPointZero;
+}
+
+
+#pragma mark - CollectionView DataSource
+
+- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
+    return self.photos.count;
+}
+
+- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
+    
+    PhotoPreviewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"PhotoPreviewCell" forIndexPath:indexPath];
+    
+    return cell;
+}
+
+#pragma mark - ScrollView Delegate
+
+- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
+    if (scrollView != self.previewContainer) {
+        return scrollView.subviews.firstObject;
+    }
+    return nil;
+}
+
+- (void)scrollViewDidZoom:(UIScrollView *)scrollView {
+    if (self.previewContainer != scrollView) {
+        CGFloat width = CGRectGetWidth(self.previewContainer.bounds);
+        CGFloat height = CGRectGetHeight(self.previewContainer.bounds);
+        
+        CGSize itemSize = [self itemSize:self.currentIndex];
+        CGSize contentSize = scrollView.contentSize;
+        contentSize.width += (width - itemSize.width);
+        contentSize.height += (height - itemSize.height);
+        scrollView.contentSize = contentSize;
+    }
+}
+
+- (CGSize)itemSize:(NSUInteger)index {
+    
+    CGFloat width = CGRectGetWidth(self.previewContainer.bounds);
+    CGFloat height = CGRectGetHeight(self.previewContainer.bounds);
+    CGSize size = CGSizeMake(width, height);
+    
+    NSDictionary *item = [self.photos objectAtIndex:index];
+    UIImage *img = [UIImage imageWithContentsOfFile:[item objectForKey:@"path"]];
+    CGFloat w = img.size.width;
+    CGFloat h = img.size.height;
+    // 根据图片大小和ScrollView大小等比缩放,使ScrollView容得下图片
+    float factor = MAX(w / width, h / height);
+    factor = 1 / factor * 0.8;
+    
+    size = CGSizeMake(w * factor, h * factor);
+    return size;
+}
+
+
+@end

+ 84 - 0
RA Image/RA Image/PhotoList.storyboard

@@ -187,6 +187,90 @@
             </objects>
             <point key="canvasLocation" x="1019" y="71"/>
         </scene>
+        <!--New Photo Preview Controller-->
+        <scene sceneID="U3N-xr-7Rz">
+            <objects>
+                <viewController storyboardIdentifier="NewPhotoPreviewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="qZK-Vy-gaw" customClass="NewPhotoPreviewController" sceneMemberID="viewController">
+                    <layoutGuides>
+                        <viewControllerLayoutGuide type="top" id="mc4-Qg-2g3"/>
+                        <viewControllerLayoutGuide type="bottom" id="0pB-uU-kJr"/>
+                    </layoutGuides>
+                    <view key="view" contentMode="scaleToFill" id="qtX-co-R7G">
+                        <rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <subviews>
+                            <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="eUk-3I-LIa">
+                                <rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
+                                <color key="backgroundColor" red="1" green="0.053315131760000002" blue="0.038905751279999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                <collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" minimumLineSpacing="10" minimumInteritemSpacing="10" id="AhJ-66-sid">
+                                    <size key="itemSize" width="414" height="735"/>
+                                    <size key="headerReferenceSize" width="0.0" height="0.0"/>
+                                    <size key="footerReferenceSize" width="0.0" height="0.0"/>
+                                    <inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
+                                </collectionViewFlowLayout>
+                                <cells>
+                                    <collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="PhotoPreviewCell" id="eAR-El-bRn" customClass="PhotoPreviewCell">
+                                        <rect key="frame" x="0.0" y="0.66666666666666663" width="414" height="735"/>
+                                        <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                        <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
+                                            <rect key="frame" x="0.0" y="0.0" width="414" height="735"/>
+                                            <autoresizingMask key="autoresizingMask"/>
+                                            <subviews>
+                                                <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="5Dl-d3-MLq">
+                                                    <rect key="frame" x="0.0" y="0.0" width="414" height="735"/>
+                                                    <color key="backgroundColor" red="0.064155410240000002" green="1" blue="0.59383154270000005" alpha="1" colorSpace="calibratedRGB"/>
+                                                </scrollView>
+                                            </subviews>
+                                        </view>
+                                        <color key="backgroundColor" red="0.2190771869" green="0.711363619" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                        <constraints>
+                                            <constraint firstItem="5Dl-d3-MLq" firstAttribute="width" secondItem="eAR-El-bRn" secondAttribute="width" id="OwB-eR-E1R"/>
+                                            <constraint firstItem="5Dl-d3-MLq" firstAttribute="centerY" secondItem="eAR-El-bRn" secondAttribute="centerY" id="hQv-Uz-CBO"/>
+                                            <constraint firstItem="5Dl-d3-MLq" firstAttribute="centerX" secondItem="eAR-El-bRn" secondAttribute="centerX" id="nsu-Oh-hQQ"/>
+                                            <constraint firstItem="5Dl-d3-MLq" firstAttribute="height" secondItem="eAR-El-bRn" secondAttribute="height" id="wst-oN-7pA"/>
+                                        </constraints>
+                                        <size key="customSize" width="414" height="735"/>
+                                        <connections>
+                                            <outlet property="scrollView" destination="5Dl-d3-MLq" id="2Gj-Oc-6rO"/>
+                                        </connections>
+                                    </collectionViewCell>
+                                </cells>
+                                <connections>
+                                    <outlet property="dataSource" destination="qZK-Vy-gaw" id="2qY-wX-LI0"/>
+                                    <outlet property="delegate" destination="qZK-Vy-gaw" id="Fnz-nQ-4PE"/>
+                                </connections>
+                            </collectionView>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="1 / 8" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="x3F-Hb-jne">
+                                <rect key="frame" x="167" y="30" width="80" height="40"/>
+                                <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                <constraints>
+                                    <constraint firstAttribute="width" constant="80" id="4nS-MH-dz0"/>
+                                    <constraint firstAttribute="height" constant="40" id="jTZ-mK-h0Z"/>
+                                </constraints>
+                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                <color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
+                                <nil key="highlightedColor"/>
+                            </label>
+                        </subviews>
+                        <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
+                        <constraints>
+                            <constraint firstItem="eUk-3I-LIa" firstAttribute="centerX" secondItem="qtX-co-R7G" secondAttribute="centerX" id="Occ-gY-Cbn"/>
+                            <constraint firstItem="x3F-Hb-jne" firstAttribute="top" secondItem="mc4-Qg-2g3" secondAttribute="bottom" constant="10" id="PCn-1c-2Pu"/>
+                            <constraint firstItem="x3F-Hb-jne" firstAttribute="centerX" secondItem="qtX-co-R7G" secondAttribute="centerX" id="Vpc-xd-gDa"/>
+                            <constraint firstItem="eUk-3I-LIa" firstAttribute="height" secondItem="qtX-co-R7G" secondAttribute="height" id="dad-0B-yAf"/>
+                            <constraint firstItem="eUk-3I-LIa" firstAttribute="width" secondItem="qtX-co-R7G" secondAttribute="width" id="nY6-mM-Sjc"/>
+                            <constraint firstItem="eUk-3I-LIa" firstAttribute="centerY" secondItem="qtX-co-R7G" secondAttribute="centerY" id="ygr-Ka-rvN"/>
+                        </constraints>
+                    </view>
+                    <connections>
+                        <outlet property="indicator" destination="x3F-Hb-jne" id="JGA-vq-BPK"/>
+                        <outlet property="previewContainer" destination="eUk-3I-LIa" id="TYz-ym-JNG"/>
+                    </connections>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="sWf-Id-XaR" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="1871.0144927536232" y="50.54347826086957"/>
+        </scene>
     </scenes>
     <resources>
         <image name="checkbox" width="16" height="16"/>

+ 7 - 3
RA Image/RA Image/PhotoListViewController.m

@@ -10,6 +10,7 @@
 #import "PhotoCell.h"
 #import "PhotoPreviewController.h"
 #import "BasicModeViewController.h"
+#import "NewPhotoPreviewController.h"
 
 @interface PhotoListViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,PhotoCellDelegate>
 
@@ -116,11 +117,13 @@
 
 - (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath {
     NSDictionary *item = [self.photos objectAtIndex:indexPath.row];
-    UIImage *img = [item objectForKey:@"photo"];
+    
+    UIImage *img = [UIImage imageWithContentsOfFile:[item objectForKey:@"path"]];
+    UIImage *thumb = [RAUtils scaleToSize:img size:CGSizeMake(150, 150)];
     BOOL check = [[item objectForKey:@"check"] boolValue];
     
     PhotoCell *photoCell = (PhotoCell *)cell;
-    photoCell.photo = img;
+    photoCell.photo = thumb;
     photoCell.checkBtn.selected = check;
 }
 
@@ -132,7 +135,8 @@
 
 - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
     // 点击Cell不响应需要在viewDidLoad方法中removeFirstResponderTap
-    PhotoPreviewController *previewVC = (PhotoPreviewController *)[self viewControllerInStoryboard:@"PhotoList" withId:@"PhotoPreviewController"];
+//    PhotoPreviewController *previewVC = (PhotoPreviewController *)[self viewControllerInStoryboard:@"PhotoList" withId:@"PhotoPreviewController"];
+    NewPhotoPreviewController *previewVC = (NewPhotoPreviewController *)[self viewControllerInStoryboard:@"PhotoList" withId:@"NewPhotoPreviewController"];
     previewVC.photos = self.photos;
     previewVC.currentIndex = indexPath.row;
     [self.navigationController pushViewController:previewVC animated:YES];

+ 14 - 0
RA Image/RA Image/PhotoPreviewCell.h

@@ -0,0 +1,14 @@
+//
+//  PhotoPreviewCell.h
+//  RA Image
+//
+//  Created by Jack on 2017/6/14.
+//  Copyright © 2017年 USAI. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface PhotoPreviewCell : UICollectionViewCell
+@property (strong, nonatomic) IBOutlet UIScrollView *scrollView;
+
+@end

+ 13 - 0
RA Image/RA Image/PhotoPreviewCell.m

@@ -0,0 +1,13 @@
+//
+//  PhotoPreviewCell.m
+//  RA Image
+//
+//  Created by Jack on 2017/6/14.
+//  Copyright © 2017年 USAI. All rights reserved.
+//
+
+#import "PhotoPreviewCell.h"
+
+@implementation PhotoPreviewCell
+
+@end

+ 3 - 3
RA Image/RA Image/PhotoPreviewController.m

@@ -50,7 +50,7 @@
     CGSize size = CGSizeMake(width, height);
     
     NSDictionary *item = [self.photos objectAtIndex:index];
-    UIImage *img = [item objectForKey:@"photo"];
+     UIImage *img = [UIImage imageWithContentsOfFile:[item objectForKey:@"path"]];
     
     CGFloat w = img.size.width;
     CGFloat h = img.size.height;
@@ -79,8 +79,8 @@
         [self.previewScroll addSubview:sc];
 
         NSDictionary *item = [self.photos objectAtIndex:i];
-        UIImage *img = [item objectForKey:@"photo"];
-        
+        UIImage *img = [UIImage imageWithContentsOfFile:[item objectForKey:@"path"]];
+
         CGFloat w = img.size.width;
         CGFloat h = img.size.height;
         // 根据图片大小和ScrollView大小等比缩放,使ScrollView容得下图片