Initial commit
This commit is contained in:
+93
@@ -0,0 +1,93 @@
|
||||
//
|
||||
// ShootImgDataSource.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 16/6/24.
|
||||
// Copyright © 2016年 lianxiang. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ShootImgDataSource.h"
|
||||
#import "KTPhotoView+SDWebImage.h"
|
||||
#import "KTThumbView+SDWebImage.h"
|
||||
#import "AppDelegate.h"
|
||||
#import "UDManager.h"
|
||||
#import "LoginResult.h"
|
||||
#import "Utils.h"
|
||||
#define FULL_SIZE_INDEX 0
|
||||
#define THUMBNAIL_INDEX 1
|
||||
@implementation ShootImgDataSource
|
||||
- (id)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
|
||||
//remove imagePaths
|
||||
[self.screenshotPaths removeAllObjects];
|
||||
//image files
|
||||
NSArray *datas = [NSArray arrayWithArray:[Utils getScreenshotFiles]];
|
||||
|
||||
self.screenshotPaths = [NSMutableArray arrayWithCapacity:0];
|
||||
for (NSString *imageName in datas) {
|
||||
NSString *imagePath = [Utils getScreenshotFilePathWithName:imageName];
|
||||
[self.screenshotPaths addObject:imagePath];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
#pragma mark KTPhotoBrowserDataSource
|
||||
|
||||
- (void)deleteImageAtIndex:(NSInteger)index{//保存图片到相册
|
||||
//首先,先删除手机本地的图片
|
||||
NSFileManager *manager = [NSFileManager defaultManager];
|
||||
NSError *error;
|
||||
NSString *imagePath = [self.screenshotPaths objectAtIndex:index];
|
||||
[manager removeItemAtPath:imagePath error:&error];
|
||||
if(error){
|
||||
//DLog(@"%@",error);
|
||||
}
|
||||
|
||||
//再删除资源图片数组
|
||||
[self.screenshotPaths removeObjectAtIndex:index];
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfPhotos {
|
||||
NSInteger count = [self.screenshotPaths count];
|
||||
return count;
|
||||
}
|
||||
|
||||
//selected image
|
||||
- (void)imageAtIndex:(NSInteger)index photoView:(KTPhotoView *)photoView {
|
||||
|
||||
NSString *imagePath = [self.screenshotPaths objectAtIndex:index];
|
||||
UIImage *image = [UIImage imageWithContentsOfFile:imagePath];
|
||||
[photoView setImage:image];
|
||||
//
|
||||
// if ([[AppDelegate sharedDefault]dwApContactID] == 0) {
|
||||
// MainController *mainController = [AppDelegate sharedDefault].mainController;
|
||||
// [mainController setBottomBarHidden:YES];
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// MainController *mainController = [AppDelegate sharedDefault].mainController_ap;
|
||||
// [mainController setBottomBarHidden:YES];
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
- (UIImage *)imageAtIndex:(NSInteger)index{
|
||||
|
||||
NSString *imagePath = [self.screenshotPaths objectAtIndex:index];
|
||||
UIImage *image = [UIImage imageWithContentsOfFile:imagePath];
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
- (void)thumbImageAtIndex:(NSInteger)index thumbView:(KTThumbView *)thumbView {
|
||||
|
||||
NSString *imagePath = [self.screenshotPaths objectAtIndex:index];
|
||||
UIImage *image = [UIImage imageWithContentsOfFile:imagePath];
|
||||
[thumbView setThumbImage:image];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user