Ver código fonte

1.完成iOS图像预览,当只有一张图片时,索引不对。

Pen Li 7 anos atrás
pai
commit
b3758e248a

+ 11 - 1
common/InfinitePhoto/Controller/RAPhotoPreviewController.m

@@ -43,6 +43,7 @@
 
 
 @property (nonatomic,strong) NSArray<id<RAPhotoItemDelegate>> *photos;
 @property (nonatomic,strong) NSArray<id<RAPhotoItemDelegate>> *photos;
 @property (nonatomic,assign) NSUInteger offset;
 @property (nonatomic,assign) NSUInteger offset;
+@property (nonatomic,assign) NSUInteger photoCount;
 
 
 @property (nonatomic,assign) BOOL hideNavigationBar;
 @property (nonatomic,assign) BOOL hideNavigationBar;
 @property (nonatomic,assign) BOOL initialized;
 @property (nonatomic,assign) BOOL initialized;
@@ -63,6 +64,12 @@
         [tmpArr addObject:placeHolder];
         [tmpArr addObject:placeHolder];
         
         
         items = tmpArr;
         items = tmpArr;
+        
+        vc.photoCount = 1;
+        
+    } else {
+        
+        vc.photoCount = items.count;
     }
     }
     
     
     if (offset == 0 || offset >= items.count) {
     if (offset == 0 || offset >= items.count) {
@@ -248,7 +255,10 @@
      
      
      */
      */
     NSUInteger index = (self.currentIndex + self.offset) % self.photos.count + 1;
     NSUInteger index = (self.currentIndex + self.offset) % self.photos.count + 1;
-    NSString *offset = [NSString stringWithFormat:@"%lu / %lu",index,(unsigned long)self.photos.count];
+    if (self.photoCount == 1) {
+        index = 1;
+    }
+    NSString *offset = [NSString stringWithFormat:@"%lu / %lu",index,(unsigned long)self.photoCount];
     self.indicator.text = offset;
     self.indicator.text = offset;
 }
 }