mirror of
https://github.com/leanote/leanote-ios.git
synced 2025-10-22 03:44:52 +00:00
图片gallery
This commit is contained in:
@@ -1428,7 +1428,7 @@
|
|||||||
TestTargetID = 1D921D98173CB5BD00168A77;
|
TestTargetID = 1D921D98173CB5BD00168A77;
|
||||||
};
|
};
|
||||||
1D921D98173CB5BD00168A77 = {
|
1D921D98173CB5BD00168A77 = {
|
||||||
DevelopmentTeam = 926WD5ZF5V;
|
DevelopmentTeam = 73SX2YAJUE;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -1978,8 +1978,8 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
|
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
CODE_SIGN_IDENTITY = "iPhone Distribution: Tie Li (926WD5ZF5V)";
|
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: Tie Li (926WD5ZF5V)";
|
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||||
GCC_PREFIX_HEADER = "Leanote/Leanote-Prefix.pch";
|
GCC_PREFIX_HEADER = "Leanote/Leanote-Prefix.pch";
|
||||||
@@ -2002,9 +2002,9 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"$(PROJECT_DIR)/Leanote/view/activity/WeixinActivity/Resources",
|
"$(PROJECT_DIR)/Leanote/view/activity/WeixinActivity/Resources",
|
||||||
);
|
);
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.leanote.app.ios.Leanote;
|
PRODUCT_BUNDLE_IDENTIFIER = com.leanote.app.ios.debug.Leanote;
|
||||||
PRODUCT_NAME = Leanote;
|
PRODUCT_NAME = Leanote;
|
||||||
PROVISIONING_PROFILE = "17a6e366-009c-45d2-99cd-8ed2f4d16766";
|
PROVISIONING_PROFILE = "";
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
WRAPPER_EXTENSION = app;
|
WRAPPER_EXTENSION = app;
|
||||||
};
|
};
|
||||||
@@ -2017,8 +2017,8 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
|
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
CODE_SIGN_IDENTITY = "iPhone Distribution: Tie Li (926WD5ZF5V)";
|
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: Tie Li (926WD5ZF5V)";
|
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||||
GCC_PREFIX_HEADER = "Leanote/Leanote-Prefix.pch";
|
GCC_PREFIX_HEADER = "Leanote/Leanote-Prefix.pch";
|
||||||
@@ -2041,9 +2041,9 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"$(PROJECT_DIR)/Leanote/view/activity/WeixinActivity/Resources",
|
"$(PROJECT_DIR)/Leanote/view/activity/WeixinActivity/Resources",
|
||||||
);
|
);
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.leanote.app.ios.Leanote;
|
PRODUCT_BUNDLE_IDENTIFIER = com.leanote.app.ios.debug.Leanote;
|
||||||
PRODUCT_NAME = Leanote;
|
PRODUCT_NAME = Leanote;
|
||||||
PROVISIONING_PROFILE = "17a6e366-009c-45d2-99cd-8ed2f4d16766";
|
PROVISIONING_PROFILE = "";
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
WRAPPER_EXTENSION = app;
|
WRAPPER_EXTENSION = app;
|
||||||
};
|
};
|
||||||
|
@@ -535,21 +535,25 @@ BOOL hiddenBar = NO;
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// TODO 有个action保存到本地图片中
|
// image gallery
|
||||||
- (void)showActionTapImage:(NSString *)url
|
- (void)showActionTapImage:(NSString *)url
|
||||||
{
|
{
|
||||||
NSArray *urlArr = [url componentsSeparatedByString:@","]; // 以','分隔, 最后一个是当前url
|
NSArray *urlArr = [url componentsSeparatedByString:@"L$L"]; // 以'L$L'分隔, 最后一个是当前url
|
||||||
NSString *curUrlStr = [urlArr lastObject];
|
|
||||||
|
// 最后一个是当前位置
|
||||||
|
int curUrlIndex = [[urlArr lastObject] intValue];
|
||||||
|
|
||||||
NSMutableArray *realUrls = [[NSMutableArray alloc] init];
|
NSMutableArray *realUrls = [[NSMutableArray alloc] init];
|
||||||
|
|
||||||
// fix url, 整理出可以显示的图片
|
// fix url, 整理出可以显示的图片
|
||||||
for(int i = 0; i < [urlArr count] - 1; ++i) {
|
for(int i = 0; i < [urlArr count] - 1; ++i) {
|
||||||
NSString *each = urlArr[i];
|
NSString *each = urlArr[i];
|
||||||
|
|
||||||
NSString *fileId = [Common getFileIdFromUrl:each];
|
// 只要是图片, 都行, 因为有些图片是没有.png后缀的
|
||||||
if(fileId || [LeaImageViewController isUrlSupported:[NSURL URLWithString:each]]) {
|
// NSString *fileId = [Common getFileIdFromUrl:each];
|
||||||
|
// if(fileId || [LeaImageViewController isUrlSupported:[NSURL URLWithString:each]]) {
|
||||||
[realUrls addObject:each];
|
[realUrls addObject:each];
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// 得到当前的url
|
// 得到当前的url
|
||||||
@@ -557,7 +561,13 @@ BOOL hiddenBar = NO;
|
|||||||
if(count < 1) {
|
if(count < 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (curUrlIndex > count) {
|
||||||
|
curUrlIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
int curIndex = 0;
|
int curIndex = 0;
|
||||||
|
// 如果有多张图片是一样的url呢?
|
||||||
NSString *curUrl = realUrls[0];
|
NSString *curUrl = realUrls[0];
|
||||||
for(int i = 0; i < count; ++i) {
|
for(int i = 0; i < count; ++i) {
|
||||||
NSString *each = realUrls[i];
|
NSString *each = realUrls[i];
|
||||||
@@ -567,11 +577,12 @@ BOOL hiddenBar = NO;
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
LeaImageSliderViewController *vc2 = [[LeaImageSliderViewController alloc] init];
|
LeaImageSliderViewController *vc2 = [[LeaImageSliderViewController alloc] init];
|
||||||
vc2.curUrl = curUrl;
|
vc2.curUrl = realUrls[curUrlIndex];
|
||||||
vc2.urlArr = realUrls;
|
[vc2 setUrlArr:realUrls];
|
||||||
vc2.curIndex = curIndex;
|
vc2.curIndex = curUrlIndex;
|
||||||
vc2.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
|
vc2.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
|
||||||
vc2.modalPresentationStyle = UIModalPresentationFullScreen;
|
vc2.modalPresentationStyle = UIModalPresentationFullScreen;
|
||||||
[self presentViewController:vc2 animated:YES completion:nil];
|
[self presentViewController:vc2 animated:YES completion:nil];
|
||||||
|
@@ -2695,16 +2695,24 @@ ZSSField.prototype.sendImageTappedCallback = function( imageNode ) {
|
|||||||
|
|
||||||
// 得到所有的image urls
|
// 得到所有的image urls
|
||||||
var allImages = [];
|
var allImages = [];
|
||||||
|
var curIndex = 0;
|
||||||
|
var curElem = $(imageNode).get(0);
|
||||||
|
var i = 0;
|
||||||
$('#zss_field_content img').each(function() {
|
$('#zss_field_content img').each(function() {
|
||||||
var url = $(this).attr('src')
|
var url = $(this).attr('src')
|
||||||
if (url) {
|
if (url) {
|
||||||
allImages.push(encodeURIComponent(url));
|
allImages.push(encodeURIComponent(url));
|
||||||
|
if ($(this).get(0) == curElem) {
|
||||||
|
curIndex = i;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
allImages.push(encodeURIComponent( imageNode.src ));
|
// allImages.push(encodeURIComponent( imageNode.src ));
|
||||||
|
allImages.push(curIndex);
|
||||||
|
|
||||||
var arguments = ['id=' + (editable ? '1' : '0'),
|
var arguments = ['id=' + (editable ? '1' : '0'),
|
||||||
'url=' + allImages.join(','),
|
'url=' + allImages.join('L$L'),
|
||||||
'meta=' + encodeURIComponent( meta )];
|
'meta=' + encodeURIComponent( meta )];
|
||||||
|
|
||||||
var joinedArguments = arguments.join( defaultCallbackSeparator );
|
var joinedArguments = arguments.join( defaultCallbackSeparator );
|
||||||
|
File diff suppressed because one or more lines are too long
@@ -147,15 +147,22 @@ var LEAMD = {
|
|||||||
|
|
||||||
// 所有image
|
// 所有image
|
||||||
var allImages = [];
|
var allImages = [];
|
||||||
|
var curIndex = 0;
|
||||||
|
var curElem = $(this).get(0);
|
||||||
|
var i = 0;
|
||||||
$('#preview-contents img').each(function() {
|
$('#preview-contents img').each(function() {
|
||||||
var url = $(this).attr('src')
|
var url = $(this).attr('src');
|
||||||
if(url) {
|
if(url) {
|
||||||
allImages.push(url);
|
allImages.push(url);
|
||||||
|
if ($(this).get(0) == curElem) {
|
||||||
|
curIndex = i;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
allImages.push(src);
|
allImages.push(curIndex);
|
||||||
callObjc('callback-image-tap:id=0~url=' + allImages.join(',')); // + '~meta='
|
callObjc('callback-image-tap:id=0~url=' + allImages.join('L$L')); // + '~meta='
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var href = $(this).attr('href');
|
var href = $(this).attr('href');
|
||||||
|
22
Leanote/resources/AppImages.xcassets/warning.imageset/Contents.json
vendored
Normal file
22
Leanote/resources/AppImages.xcassets/warning.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"filename" : "warning.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"filename" : "warning@2x 2.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"version" : 1,
|
||||||
|
"author" : "xcode"
|
||||||
|
}
|
||||||
|
}
|
BIN
Leanote/resources/AppImages.xcassets/warning.imageset/warning.png
vendored
Normal file
BIN
Leanote/resources/AppImages.xcassets/warning.imageset/warning.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
BIN
Leanote/resources/AppImages.xcassets/warning.imageset/warning@2x 2.png
vendored
Normal file
BIN
Leanote/resources/AppImages.xcassets/warning.imageset/warning@2x 2.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
@@ -18,4 +18,6 @@
|
|||||||
@property (strong, nonatomic) NSString *curUrl;
|
@property (strong, nonatomic) NSString *curUrl;
|
||||||
@property NSUInteger curIndex;
|
@property NSUInteger curIndex;
|
||||||
|
|
||||||
|
-(void)setUrlArr:(NSArray *)urlArr;
|
||||||
|
|
||||||
@end
|
@end
|
@@ -119,6 +119,10 @@
|
|||||||
// [self dismissViewControllerAnimated:YES completion:nil];
|
// [self dismissViewControllerAnimated:YES completion:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 设置urlArr
|
||||||
|
-(void)setUrlArr:(NSArray *)urlArr {
|
||||||
|
_urlArr = urlArr;
|
||||||
|
}
|
||||||
|
|
||||||
// 初始化所有数据
|
// 初始化所有数据
|
||||||
- (BOOL) createContentPages {
|
- (BOOL) createContentPages {
|
||||||
@@ -146,15 +150,19 @@
|
|||||||
NSURL *u = [NSURL URLWithString:url];
|
NSURL *u = [NSURL URLWithString:url];
|
||||||
NSString *fileId = [Common getFileIdFromUrl:url];
|
NSString *fileId = [Common getFileIdFromUrl:url];
|
||||||
UIImage *img;
|
UIImage *img;
|
||||||
if(fileId) {
|
|
||||||
if(fileId) {
|
if(![Common isNull:fileId]) {
|
||||||
NSString *absPath = [FileService getFileAbsPathByFileIdOrServerFileId:fileId];
|
NSString *absPath = [FileService getFileAbsPathByFileIdOrServerFileId:fileId];
|
||||||
|
if (![Common isNull:absPath]) {
|
||||||
img = [[UIImage alloc] initWithContentsOfFile:absPath];
|
img = [[UIImage alloc] initWithContentsOfFile:absPath];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vc = [[LeaImageViewController alloc] initWithImage:img andURL:u];
|
vc = [[LeaImageViewController alloc] initWithImage:img andURL:u];
|
||||||
|
vc.urlIndex = index; // urlIndex
|
||||||
|
|
||||||
self.views[index] = vc;
|
self.views[index] = vc;
|
||||||
|
|
||||||
// [self.views setValue:vc forKey:index];
|
// [self.views setValue:vc forKey:index];
|
||||||
|
|
||||||
vc.willAppear = ^(void) {
|
vc.willAppear = ^(void) {
|
||||||
@@ -173,7 +181,9 @@
|
|||||||
|
|
||||||
// 返回上一个ViewController对象
|
// 返回上一个ViewController对象
|
||||||
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController{
|
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController{
|
||||||
NSUInteger index = [self indexOfViewController:(LeaImageViewController *)viewController];
|
|
||||||
|
NSUInteger index = ((LeaImageViewController *)viewController).urlIndex; // [self indexOfViewController:(LeaImageViewController *)viewController];
|
||||||
|
|
||||||
if ((index == 0) || (index == NSNotFound)) {
|
if ((index == 0) || (index == NSNotFound)) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
@@ -186,8 +196,9 @@
|
|||||||
|
|
||||||
// 返回下一个ViewController对象
|
// 返回下一个ViewController对象
|
||||||
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController{
|
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController{
|
||||||
|
|
||||||
NSUInteger index = [self indexOfViewController:(LeaImageViewController *)viewController];
|
NSUInteger index = ((LeaImageViewController *)viewController).urlIndex;
|
||||||
|
// NSUInteger index = [self indexOfViewController:(LeaImageViewController *)viewController];
|
||||||
|
|
||||||
if (index == NSNotFound) {
|
if (index == NSNotFound) {
|
||||||
return nil;
|
return nil;
|
||||||
@@ -206,7 +217,7 @@
|
|||||||
transitionCompleted:(BOOL)completed
|
transitionCompleted:(BOOL)completed
|
||||||
{
|
{
|
||||||
if(completed) {
|
if(completed) {
|
||||||
NSUInteger index = [self indexOfViewController:(LeaImageViewController *)[pageViewController.viewControllers lastObject]];
|
NSUInteger index = ((LeaImageViewController *)[pageViewController.viewControllers lastObject]).urlIndex;
|
||||||
self.curIndex = index;
|
self.curIndex = index;
|
||||||
[self setIndexLabel];
|
[self setIndexLabel];
|
||||||
}
|
}
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
@interface LeaImageViewController : UIViewController
|
@interface LeaImageViewController : UIViewController
|
||||||
|
|
||||||
@property (nonatomic, strong) NSURL *url;
|
@property (nonatomic, strong) NSURL *url;
|
||||||
|
@property NSUInteger urlIndex;
|
||||||
@property (nonatomic, strong) UIImage *image;
|
@property (nonatomic, strong) UIImage *image;
|
||||||
|
|
||||||
@property (nonatomic, strong) void (^willAppear)(void);
|
@property (nonatomic, strong) void (^willAppear)(void);
|
||||||
|
@@ -16,6 +16,7 @@ static CGFloat const MinimumZoomScale = 0.1;
|
|||||||
@property (nonatomic, assign) BOOL shouldHideStatusBar;
|
@property (nonatomic, assign) BOOL shouldHideStatusBar;
|
||||||
@property (nonatomic, strong) UIActivityIndicatorView *activityIndicatorView;
|
@property (nonatomic, strong) UIActivityIndicatorView *activityIndicatorView;
|
||||||
@property (nonatomic, strong) UIButton *saveBtn;
|
@property (nonatomic, strong) UIButton *saveBtn;
|
||||||
|
@property (nonatomic, strong) UIImage *errorImage;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@@ -104,6 +105,8 @@ static CGFloat const MinimumZoomScale = 0.1;
|
|||||||
self.saveBtn = myButton;
|
self.saveBtn = myButton;
|
||||||
self.saveBtn.hidden = YES;
|
self.saveBtn.hidden = YES;
|
||||||
|
|
||||||
|
self.errorImage = [UIImage imageNamed:@"warning"];
|
||||||
|
|
||||||
[self loadImage];
|
[self loadImage];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,12 +116,15 @@ static CGFloat const MinimumZoomScale = 0.1;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 本地图片
|
||||||
if (self.image != nil) {
|
if (self.image != nil) {
|
||||||
|
|
||||||
self.imageView.image = self.image;
|
self.imageView.image = self.image;
|
||||||
[self.imageView sizeToFit];
|
[self.imageView sizeToFit];
|
||||||
self.scrollView.contentSize = self.imageView.image.size;
|
self.scrollView.contentSize = self.imageView.image.size;
|
||||||
[self centerImage];
|
[self centerImage];
|
||||||
|
|
||||||
|
// 下载图片
|
||||||
} else if (self.url) {
|
} else if (self.url) {
|
||||||
self.isLoadingImage = YES;
|
self.isLoadingImage = YES;
|
||||||
[self.activityIndicatorView startAnimating];
|
[self.activityIndicatorView startAnimating];
|
||||||
@@ -131,18 +137,27 @@ static CGFloat const MinimumZoomScale = 0.1;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
[strongSelf.activityIndicatorView stopAnimating];
|
[strongSelf.activityIndicatorView stopAnimating];
|
||||||
|
|
||||||
strongSelf.image = image;
|
strongSelf.image = image;
|
||||||
weakSelf.saveBtn.enabled = YES;
|
weakSelf.saveBtn.enabled = YES;
|
||||||
strongSelf.imageView.image = image;
|
strongSelf.imageView.image = image;
|
||||||
[strongSelf.imageView sizeToFit];
|
[strongSelf.imageView sizeToFit];
|
||||||
strongSelf.scrollView.contentSize = strongSelf.imageView.image.size;
|
strongSelf.scrollView.contentSize = strongSelf.imageView.image.size;
|
||||||
[strongSelf centerImage];
|
[strongSelf centerImage];
|
||||||
|
|
||||||
strongSelf.isLoadingImage = NO;
|
strongSelf.isLoadingImage = NO;
|
||||||
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
|
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
|
||||||
// DDLogError(@"Error loading image: %@", error);
|
|
||||||
__typeof__(self) strongSelf = weakSelf;
|
__typeof__(self) strongSelf = weakSelf;
|
||||||
[strongSelf.activityIndicatorView stopAnimating];
|
[strongSelf.activityIndicatorView stopAnimating];
|
||||||
strongSelf.isLoadingImage = NO;
|
strongSelf.isLoadingImage = NO;
|
||||||
|
|
||||||
|
strongSelf.image = strongSelf.errorImage;
|
||||||
|
weakSelf.saveBtn.enabled = YES;
|
||||||
|
strongSelf.imageView.image = strongSelf.errorImage;
|
||||||
|
[strongSelf.imageView sizeToFit];
|
||||||
|
strongSelf.scrollView.contentSize = strongSelf.imageView.image.size;
|
||||||
|
[strongSelf centerImage];
|
||||||
|
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -190,16 +205,6 @@ static CGFloat const MinimumZoomScale = 0.1;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)centerImage
|
|
||||||
{
|
|
||||||
CGFloat scaleWidth = CGRectGetWidth(self.scrollView.frame) / self.imageView.image.size.width;
|
|
||||||
CGFloat scaleHeight = CGRectGetHeight(self.scrollView.frame) / self.imageView.image.size.height;
|
|
||||||
|
|
||||||
self.scrollView.minimumZoomScale = MIN(scaleWidth, scaleHeight);
|
|
||||||
self.scrollView.zoomScale = self.scrollView.minimumZoomScale;
|
|
||||||
|
|
||||||
[self scrollViewDidZoom:self.scrollView];
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)saveAs:(id)sender
|
-(void)saveAs:(id)sender
|
||||||
{
|
{
|
||||||
@@ -227,13 +232,16 @@ static CGFloat const MinimumZoomScale = 0.1;
|
|||||||
CGPoint point = [tgr locationInView:self.imageView];
|
CGPoint point = [tgr locationInView:self.imageView];
|
||||||
CGSize size = self.scrollView.frame.size;
|
CGSize size = self.scrollView.frame.size;
|
||||||
|
|
||||||
CGFloat w = size.width / self.scrollView.maximumZoomScale;
|
CGFloat w = size.width / self.scrollView.maximumZoomScale;
|
||||||
CGFloat h = size.height / self.scrollView.maximumZoomScale;
|
CGFloat h = size.height / self.scrollView.maximumZoomScale;
|
||||||
|
|
||||||
CGFloat x = point.x - (w / 2.0f);
|
CGFloat x = point.x - (w / 2.0f);
|
||||||
CGFloat y = point.y - (h / 2.0f);
|
CGFloat y = point.y - (h / 2.0f);
|
||||||
|
|
||||||
CGRect rect = CGRectMake(x, y, w, h);
|
CGRect rect = CGRectMake(x, y, w, h);
|
||||||
[self.scrollView zoomToRect:rect animated:YES];
|
[self.scrollView zoomToRect:rect animated:YES];
|
||||||
|
|
||||||
|
[self scrollViewDidZoom:self.scrollView];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - UIScrollView Delegate
|
#pragma mark - UIScrollView Delegate
|
||||||
@@ -243,6 +251,18 @@ static CGFloat const MinimumZoomScale = 0.1;
|
|||||||
return self.imageView;
|
return self.imageView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 中心化image
|
||||||
|
- (void)centerImage
|
||||||
|
{
|
||||||
|
CGFloat scaleWidth = CGRectGetWidth(self.scrollView.frame) / self.imageView.image.size.width;
|
||||||
|
CGFloat scaleHeight = CGRectGetHeight(self.scrollView.frame) / self.imageView.image.size.height;
|
||||||
|
|
||||||
|
self.scrollView.minimumZoomScale = MIN(scaleWidth, scaleHeight);
|
||||||
|
self.scrollView.zoomScale = self.scrollView.minimumZoomScale;
|
||||||
|
|
||||||
|
[self scrollViewDidZoom:self.scrollView];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)scrollViewDidZoom:(UIScrollView *)scrollView
|
- (void)scrollViewDidZoom:(UIScrollView *)scrollView
|
||||||
{
|
{
|
||||||
CGSize size = scrollView.frame.size;
|
CGSize size = scrollView.frame.size;
|
||||||
|
Reference in New Issue
Block a user