图片gallery

This commit is contained in:
life
2015-11-09 17:29:41 +08:00
parent d810141d80
commit 709c6ac835
12 changed files with 128 additions and 46 deletions

View File

@@ -1428,7 +1428,7 @@
TestTargetID = 1D921D98173CB5BD00168A77;
};
1D921D98173CB5BD00168A77 = {
DevelopmentTeam = 926WD5ZF5V;
DevelopmentTeam = 73SX2YAJUE;
};
};
};
@@ -1978,8 +1978,8 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution: Tie Li (926WD5ZF5V)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: Tie Li (926WD5ZF5V)";
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
ENABLE_BITCODE = NO;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Leanote/Leanote-Prefix.pch";
@@ -2002,9 +2002,9 @@
"$(inherited)",
"$(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;
PROVISIONING_PROFILE = "17a6e366-009c-45d2-99cd-8ed2f4d16766";
PROVISIONING_PROFILE = "";
TARGETED_DEVICE_FAMILY = "1,2";
WRAPPER_EXTENSION = app;
};
@@ -2017,8 +2017,8 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution: Tie Li (926WD5ZF5V)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: Tie Li (926WD5ZF5V)";
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
ENABLE_BITCODE = NO;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Leanote/Leanote-Prefix.pch";
@@ -2041,9 +2041,9 @@
"$(inherited)",
"$(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;
PROVISIONING_PROFILE = "17a6e366-009c-45d2-99cd-8ed2f4d16766";
PROVISIONING_PROFILE = "";
TARGETED_DEVICE_FAMILY = "1,2";
WRAPPER_EXTENSION = app;
};

View File

@@ -535,21 +535,25 @@ BOOL hiddenBar = NO;
}
*/
// TODO action
// image gallery
- (void)showActionTapImage:(NSString *)url
{
NSArray *urlArr = [url componentsSeparatedByString:@","]; // ',', url
NSString *curUrlStr = [urlArr lastObject];
NSArray *urlArr = [url componentsSeparatedByString:@"L$L"]; // 'L$L', url
//
int curUrlIndex = [[urlArr lastObject] intValue];
NSMutableArray *realUrls = [[NSMutableArray alloc] init];
// fix url,
for(int i = 0; i < [urlArr count] - 1; ++i) {
NSString *each = urlArr[i];
NSString *fileId = [Common getFileIdFromUrl:each];
if(fileId || [LeaImageViewController isUrlSupported:[NSURL URLWithString:each]]) {
// , , .png
// NSString *fileId = [Common getFileIdFromUrl:each];
// if(fileId || [LeaImageViewController isUrlSupported:[NSURL URLWithString:each]]) {
[realUrls addObject:each];
}
// }
}
// url
@@ -557,7 +561,13 @@ BOOL hiddenBar = NO;
if(count < 1) {
return;
}
if (curUrlIndex > count) {
curUrlIndex = 0;
}
/*
int curIndex = 0;
// url?
NSString *curUrl = realUrls[0];
for(int i = 0; i < count; ++i) {
NSString *each = realUrls[i];
@@ -567,11 +577,12 @@ BOOL hiddenBar = NO;
break;
}
}
*/
LeaImageSliderViewController *vc2 = [[LeaImageSliderViewController alloc] init];
vc2.curUrl = curUrl;
vc2.urlArr = realUrls;
vc2.curIndex = curIndex;
vc2.curUrl = realUrls[curUrlIndex];
[vc2 setUrlArr:realUrls];
vc2.curIndex = curUrlIndex;
vc2.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
vc2.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:vc2 animated:YES completion:nil];

View File

@@ -2695,16 +2695,24 @@ ZSSField.prototype.sendImageTappedCallback = function( imageNode ) {
// 得到所有的image urls
var allImages = [];
var curIndex = 0;
var curElem = $(imageNode).get(0);
var i = 0;
$('#zss_field_content img').each(function() {
var url = $(this).attr('src')
if (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'),
'url=' + allImages.join(','),
'url=' + allImages.join('L$L'),
'meta=' + encodeURIComponent( meta )];
var joinedArguments = arguments.join( defaultCallbackSeparator );

File diff suppressed because one or more lines are too long

View File

@@ -147,15 +147,22 @@ var LEAMD = {
// 所有image
var allImages = [];
var curIndex = 0;
var curElem = $(this).get(0);
var i = 0;
$('#preview-contents img').each(function() {
var url = $(this).attr('src')
var url = $(this).attr('src');
if(url) {
allImages.push(url);
if ($(this).get(0) == curElem) {
curIndex = i;
}
i++;
}
});
allImages.push(src);
callObjc('callback-image-tap:id=0~url=' + allImages.join(',')); // + '~meta='
allImages.push(curIndex);
callObjc('callback-image-tap:id=0~url=' + allImages.join('L$L')); // + '~meta='
}
else {
var href = $(this).attr('href');

View 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"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -18,4 +18,6 @@
@property (strong, nonatomic) NSString *curUrl;
@property NSUInteger curIndex;
-(void)setUrlArr:(NSArray *)urlArr;
@end

View File

@@ -119,6 +119,10 @@
// [self dismissViewControllerAnimated:YES completion:nil];
}
// urlArr
-(void)setUrlArr:(NSArray *)urlArr {
_urlArr = urlArr;
}
//
- (BOOL) createContentPages {
@@ -146,15 +150,19 @@
NSURL *u = [NSURL URLWithString:url];
NSString *fileId = [Common getFileIdFromUrl:url];
UIImage *img;
if(fileId) {
if(fileId) {
if(![Common isNull:fileId]) {
NSString *absPath = [FileService getFileAbsPathByFileIdOrServerFileId:fileId];
if (![Common isNull:absPath]) {
img = [[UIImage alloc] initWithContentsOfFile:absPath];
}
}
vc = [[LeaImageViewController alloc] initWithImage:img andURL:u];
vc.urlIndex = index; // urlIndex
self.views[index] = vc;
// [self.views setValue:vc forKey:index];
vc.willAppear = ^(void) {
@@ -173,7 +181,9 @@
// 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)) {
return nil;
}
@@ -187,7 +197,8 @@
// 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) {
return nil;
@@ -206,7 +217,7 @@
transitionCompleted:(BOOL)completed
{
if(completed) {
NSUInteger index = [self indexOfViewController:(LeaImageViewController *)[pageViewController.viewControllers lastObject]];
NSUInteger index = ((LeaImageViewController *)[pageViewController.viewControllers lastObject]).urlIndex;
self.curIndex = index;
[self setIndexLabel];
}

View File

@@ -3,6 +3,7 @@
@interface LeaImageViewController : UIViewController
@property (nonatomic, strong) NSURL *url;
@property NSUInteger urlIndex;
@property (nonatomic, strong) UIImage *image;
@property (nonatomic, strong) void (^willAppear)(void);

View File

@@ -16,6 +16,7 @@ static CGFloat const MinimumZoomScale = 0.1;
@property (nonatomic, assign) BOOL shouldHideStatusBar;
@property (nonatomic, strong) UIActivityIndicatorView *activityIndicatorView;
@property (nonatomic, strong) UIButton *saveBtn;
@property (nonatomic, strong) UIImage *errorImage;
@end
@@ -104,6 +105,8 @@ static CGFloat const MinimumZoomScale = 0.1;
self.saveBtn = myButton;
self.saveBtn.hidden = YES;
self.errorImage = [UIImage imageNamed:@"warning"];
[self loadImage];
}
@@ -113,12 +116,15 @@ static CGFloat const MinimumZoomScale = 0.1;
return;
}
//
if (self.image != nil) {
self.imageView.image = self.image;
[self.imageView sizeToFit];
self.scrollView.contentSize = self.imageView.image.size;
[self centerImage];
//
} else if (self.url) {
self.isLoadingImage = YES;
[self.activityIndicatorView startAnimating];
@@ -131,18 +137,27 @@ static CGFloat const MinimumZoomScale = 0.1;
return;
}
[strongSelf.activityIndicatorView stopAnimating];
strongSelf.image = image;
weakSelf.saveBtn.enabled = YES;
strongSelf.imageView.image = image;
[strongSelf.imageView sizeToFit];
strongSelf.scrollView.contentSize = strongSelf.imageView.image.size;
[strongSelf centerImage];
strongSelf.isLoadingImage = NO;
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
// DDLogError(@"Error loading image: %@", error);
__typeof__(self) strongSelf = weakSelf;
[strongSelf.activityIndicatorView stopAnimating];
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
{
@@ -229,11 +234,14 @@ static CGFloat const MinimumZoomScale = 0.1;
CGFloat w = size.width / self.scrollView.maximumZoomScale;
CGFloat h = size.height / self.scrollView.maximumZoomScale;
CGFloat x = point.x - (w / 2.0f);
CGFloat y = point.y - (h / 2.0f);
CGRect rect = CGRectMake(x, y, w, h);
[self.scrollView zoomToRect:rect animated:YES];
[self scrollViewDidZoom:self.scrollView];
}
#pragma mark - UIScrollView Delegate
@@ -243,6 +251,18 @@ static CGFloat const MinimumZoomScale = 0.1;
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
{
CGSize size = scrollView.frame.size;