Commit b364a629 authored by 曹云霄's avatar 曹云霄

修改项说明:彻底修复分享商品图片偶发性失败《图片过大》

parent 99549096
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
self.addpersonInformationButton.layer.cornerRadius = kCornerRadius; self.addpersonInformationButton.layer.cornerRadius = kCornerRadius;
self.changePersonInformationButton.layer.masksToBounds = YES; self.changePersonInformationButton.layer.masksToBounds = YES;
self.changePersonInformationButton.layer.cornerRadius = kCornerRadius; self.changePersonInformationButton.layer.cornerRadius = kCornerRadius;
self.indexPage = 1; self.indexPage = ONE;
self.customerHeader.userInteractionEnabled = YES; self.customerHeader.userInteractionEnabled = YES;
[self.customerHeader addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(customerHeaderClckAction:)]]; [self.customerHeader addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(customerHeaderClckAction:)]];
//隐藏更改客户按钮 //隐藏更改客户按钮
...@@ -347,45 +347,53 @@ ...@@ -347,45 +347,53 @@
[self ErrorMBProgressView:@"请先设置当前客户"]; [self ErrorMBProgressView:@"请先设置当前客户"];
return; return;
} }
UIAlertController *alertView = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleAlert]; // 判断应用是否有使用相机的权限
UIImagePickerController *PcCamera = [[UIImagePickerController alloc]init]; if(![BaseViewController determineCameraPermissions]){
PcCamera.delegate = self; UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"提示" message:@"请在iPad的“设置-隐私-相机”选项中,允许欧立方访问你的相机" preferredStyle:UIAlertControllerStyleAlert];
[DeviceDirectionManager instance].isHorizontal=YES; [alertVC addAction:[UIAlertAction actionWithTitle:@"知道了" style:UIAlertActionStyleCancel handler:nil]];
__weak typeof(self) weakSelf = self; [self presentViewController:alertVC animated:YES completion:nil];
[alertView addAction:[UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//拍照 }else {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { UIAlertController *alertView = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleAlert];
[PcCamera setSourceType:UIImagePickerControllerSourceTypeCamera]; UIImagePickerController *PcCamera = [[UIImagePickerController alloc]init];
PcCamera.allowsEditing = YES; PcCamera.delegate = self;
dispatch_async(dispatch_get_main_queue(), ^{ [DeviceDirectionManager instance].isHorizontal=YES;
[weakSelf presentViewController:PcCamera animated:YES completion:nil]; __weak typeof(self) weakSelf = self;
}); [alertView addAction:[UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
} //拍照
else if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
{ [PcCamera setSourceType:UIImagePickerControllerSourceTypeCamera];
[weakSelf ErrorMBProgressView:@"相机无法使用"]; PcCamera.allowsEditing = YES;
} dispatch_async(dispatch_get_main_queue(), ^{
}]]; [weakSelf presentViewController:PcCamera animated:YES completion:nil];
[alertView addAction:[UIAlertAction actionWithTitle:@"从相册选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { });
//从相册中选择 }
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) { else
[PcCamera setSourceType:UIImagePickerControllerSourceTypePhotoLibrary]; {
PcCamera.allowsEditing = YES; [weakSelf ErrorMBProgressView:@"相机无法使用"];
dispatch_async(dispatch_get_main_queue(), ^{ }
[weakSelf presentViewController:PcCamera animated:YES completion:nil]; }]];
}); [alertView addAction:[UIAlertAction actionWithTitle:@"从相册选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
} //从相册中选择
else if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
{ [PcCamera setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[weakSelf ErrorMBProgressView:@"相册无法打开"]; PcCamera.allowsEditing = YES;
} dispatch_async(dispatch_get_main_queue(), ^{
}]]; [weakSelf presentViewController:PcCamera animated:YES completion:nil];
[alertView addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { });
[alertView dismissViewControllerAnimated:YES completion:nil]; }
}]]; else
dispatch_async(dispatch_get_main_queue(), ^{ {
[weakSelf presentViewController:alertView animated:YES completion:nil]; [weakSelf ErrorMBProgressView:@"相册无法打开"];
}); }
}]];
[alertView addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
[alertView dismissViewControllerAnimated:YES completion:nil];
}]];
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf presentViewController:alertView animated:YES completion:nil];
});
}
} }
#pragma mark -拍照、从相册选择 #pragma mark -拍照、从相册选择
......
...@@ -254,9 +254,7 @@ ...@@ -254,9 +254,7 @@
// 判断应用是否有使用相机的权限 // 判断应用是否有使用相机的权限
if(![BaseViewController determineCameraPermissions]){ if(![BaseViewController determineCameraPermissions]){
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"提示" message:@"请在iPad的“设置-隐私-相机”选项中,允许欧立方访问你的相机" preferredStyle:UIAlertControllerStyleAlert]; UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"提示" message:@"请在iPad的“设置-隐私-相机”选项中,允许欧立方访问你的相机" preferredStyle:UIAlertControllerStyleAlert];
[alertVC addAction:[UIAlertAction actionWithTitle:@"知道了" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { [alertVC addAction:[UIAlertAction actionWithTitle:@"知道了" style:UIAlertActionStyleCancel handler:nil]];
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
}]];
[self presentViewController:alertVC animated:YES completion:nil]; [self presentViewController:alertVC animated:YES completion:nil];
}else { }else {
......
...@@ -77,42 +77,50 @@ ...@@ -77,42 +77,50 @@
#pragma mark -用户头像点击 #pragma mark -用户头像点击
- (void)userHeaderClickAction:(UITapGestureRecognizer *)tap - (void)userHeaderClickAction:(UITapGestureRecognizer *)tap
{ {
UIAlertController *alertView = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleAlert]; // 判断应用是否有使用相机的权限
UIImagePickerController *PcCamera = [[UIImagePickerController alloc]init]; if(![BaseViewController determineCameraPermissions]){
PcCamera.delegate = self; UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"提示" message:@"请在iPad的“设置-隐私-相机”选项中,允许欧立方访问你的相机" preferredStyle:UIAlertControllerStyleAlert];
[DeviceDirectionManager instance].isHorizontal=YES; [alertVC addAction:[UIAlertAction actionWithTitle:@"知道了" style:UIAlertActionStyleCancel handler:nil]];
[alertView addAction:[UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { [self presentViewController:alertVC animated:YES completion:nil];
//拍照
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { }else{
[PcCamera setSourceType:UIImagePickerControllerSourceTypeCamera]; UIAlertController *alertView = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleAlert];
PcCamera.allowsEditing = YES; UIImagePickerController *PcCamera = [[UIImagePickerController alloc]init];
[self presentViewController:PcCamera animated:YES completion:nil]; PcCamera.delegate = self;
} [DeviceDirectionManager instance].isHorizontal=YES;
else [alertView addAction:[UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
{ //拍照
[DeviceDirectionManager instance].isHorizontal=NO; if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
[self ErrorMBProgressView:@"相机无法使用"]; [PcCamera setSourceType:UIImagePickerControllerSourceTypeCamera];
} PcCamera.allowsEditing = YES;
}]]; [self presentViewController:PcCamera animated:YES completion:nil];
[alertView addAction:[UIAlertAction actionWithTitle:@"从相册选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { }
//从相册中选择 else
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) { {
[PcCamera setSourceType:UIImagePickerControllerSourceTypePhotoLibrary]; [DeviceDirectionManager instance].isHorizontal=NO;
PcCamera.allowsEditing = YES; [self ErrorMBProgressView:@"相机无法使用"];
[self presentViewController:PcCamera animated:YES completion:nil]; }
} }]];
else [alertView addAction:[UIAlertAction actionWithTitle:@"从相册选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
{ //从相册中选择
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
[PcCamera setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
PcCamera.allowsEditing = YES;
[self presentViewController:PcCamera animated:YES completion:nil];
}
else
{
[DeviceDirectionManager instance].isHorizontal=NO;
[self ErrorMBProgressView:@"相册无法打开"];
}
}]];
[alertView addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
[DeviceDirectionManager instance].isHorizontal=NO; [DeviceDirectionManager instance].isHorizontal=NO;
[self ErrorMBProgressView:@"相册无法打开"]; [alertView dismissViewControllerAnimated:YES completion:nil];
} }]];
}]]; [self presentViewController:alertView animated:YES completion:nil];
[alertView addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { }
[DeviceDirectionManager instance].isHorizontal=NO; }
[alertView dismissViewControllerAnimated:YES completion:nil];
}]];
[self presentViewController:alertView animated:YES completion:nil];
}
#pragma mark -拍照、从相册选择 #pragma mark -拍照、从相册选择
#pragma -mark -UIImagePickerControllerDelegate #pragma -mark -UIImagePickerControllerDelegate
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<key>CFBundleName</key> <key>CFBundleName</key>
<string>欧立方</string> <string>欧立方</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.2.8</string> <string>1.2.9</string>
<key>CFBundleURLTypes</key> <key>CFBundleURLTypes</key>
<array> <array>
<dict> <dict>
......
...@@ -155,7 +155,7 @@ ...@@ -155,7 +155,7 @@
- (void)ShowProgressView:(double)progress - (void)ShowProgressView:(double)progress
{ {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
self.TCHud.mode = MBProgressHUDModeDeterminateHorizontalBar; self.TCHud.mode = MBProgressHUDModeDeterminate;
self.TCHud.labelText = @"上传中...."; self.TCHud.labelText = @"上传中....";
self.TCHud.labelFont = [UIFont systemFontOfSize:12]; self.TCHud.labelFont = [UIFont systemFontOfSize:12];
self.TCHud.progress = progress; self.TCHud.progress = progress;
......
...@@ -263,7 +263,9 @@ ...@@ -263,7 +263,9 @@
[self ErrorMBProgressView:@"没有选择需要分享的商品"]; [self ErrorMBProgressView:@"没有选择需要分享的商品"];
return; return;
} }
UIImageWriteToSavedPhotosAlbum([self capture], self, @selector(image:didFinishSavingWithError:contextInfo:), NULL); dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
UIImageWriteToSavedPhotosAlbum([self capture], self, @selector(image:didFinishSavingWithError:contextInfo:), NULL);
});
ShareGoodsViewController *shareController = [[ShareGoodsViewController alloc]init]; ShareGoodsViewController *shareController = [[ShareGoodsViewController alloc]init];
//商品id拼接 //商品id拼接
NSMutableString *goodsID = [[NSMutableString alloc]init]; NSMutableString *goodsID = [[NSMutableString alloc]init];
...@@ -291,43 +293,51 @@ ...@@ -291,43 +293,51 @@
#pragma mark -拍照 #pragma mark -拍照
- (IBAction)TakingPhotoButtonClickAction:(UIButton *)sender { - (IBAction)TakingPhotoButtonClickAction:(UIButton *)sender {
// 判断应用是否有使用相机的权限
sender.selected = YES; if(![BaseViewController determineCameraPermissions]){
UIAlertController *alertView = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleAlert]; UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"提示" message:@"请在iPad的“设置-隐私-相机”选项中,允许欧立方访问你的相机" preferredStyle:UIAlertControllerStyleAlert];
UIImagePickerController *PcCamera = [[UIImagePickerController alloc]init]; [alertVC addAction:[UIAlertAction actionWithTitle:@"知道了" style:UIAlertActionStyleCancel handler:nil]];
PcCamera.delegate = self; [self presentViewController:alertVC animated:YES completion:nil];
[DeviceDirectionManager instance].isHorizontal=YES;
[alertView addAction:[UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { }else{
//拍照
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { sender.selected = YES;
[PcCamera setSourceType:UIImagePickerControllerSourceTypeCamera]; UIAlertController *alertView = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleAlert];
PcCamera.allowsEditing = YES; UIImagePickerController *PcCamera = [[UIImagePickerController alloc]init];
[self presentViewController:PcCamera animated:YES completion:nil]; PcCamera.delegate = self;
} [DeviceDirectionManager instance].isHorizontal=YES;
else [alertView addAction:[UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
{ //拍照
[self ErrorMBProgressView:@"相机无法使用"]; if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
sender.selected = NO; [PcCamera setSourceType:UIImagePickerControllerSourceTypeCamera];
} PcCamera.allowsEditing = YES;
}]]; [self presentViewController:PcCamera animated:YES completion:nil];
[alertView addAction:[UIAlertAction actionWithTitle:@"从相册选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { }
//从相册中选择 else
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) { {
[PcCamera setSourceType:UIImagePickerControllerSourceTypePhotoLibrary]; [self ErrorMBProgressView:@"相机无法使用"];
PcCamera.allowsEditing = YES; sender.selected = NO;
[self presentViewController:PcCamera animated:YES completion:nil]; }
} }]];
else [alertView addAction:[UIAlertAction actionWithTitle:@"从相册选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
{ //从相册中选择
[self ErrorMBProgressView:@"相册无法打开"]; if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
sender.selected = NO; [PcCamera setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
} PcCamera.allowsEditing = YES;
}]]; [self presentViewController:PcCamera animated:YES completion:nil];
[alertView addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { }
self.takingPicturesButton.selected = NO; else
[alertView dismissViewControllerAnimated:YES completion:nil]; {
}]]; [self ErrorMBProgressView:@"相册无法打开"];
[self presentViewController:alertView animated:YES completion:nil]; sender.selected = NO;
}
}]];
[alertView addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
self.takingPicturesButton.selected = NO;
[alertView dismissViewControllerAnimated:YES completion:nil];
}]];
[self presentViewController:alertView animated:YES completion:nil];
}
} }
#pragma mark -拍照、从相册选择 #pragma mark -拍照、从相册选择
......
...@@ -146,12 +146,12 @@ ...@@ -146,12 +146,12 @@
/** /**
* 服务器测试地址 * 服务器测试地址
*/ */
#define SERVERREQUESTURL(URL) [NSString stringWithFormat:@"http://dg-dev.opple.com/opple-web/app%@",URL] //#define SERVERREQUESTURL(URL) [NSString stringWithFormat:@"http://dg-dev.opple.com/opple-web/app%@",URL]
//** //**
// * 服务器正式地址 // * 服务器正式地址
// */ // */
//#define SERVERREQUESTURL(URL) [NSString stringWithFormat:@"http://dg.opple.com/opple-web/app%@",URL] #define SERVERREQUESTURL(URL) [NSString stringWithFormat:@"http://dg.opple.com/opple-web/app%@",URL]
/** /**
* 搜索框输入通知 * 搜索框输入通知
......
...@@ -16,13 +16,14 @@ ...@@ -16,13 +16,14 @@
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
// Do any additional setup after loading the view from its nib.
} }
- (void)didReceiveMemoryWarning { #pragma mark - 压缩图片
[super didReceiveMemoryWarning]; - (void)setShareImage:(UIImage *)shareImage
// Dispose of any resources that can be recreated. {
_shareImage = [UIImage imageWithData:UIImageJPEGRepresentation(shareImage, 0.2)];
} }
#pragma mark -分享 #pragma mark -分享
- (IBAction)ShareWeiChatAntWeiboAction:(UIButton *)sender { - (IBAction)ShareWeiChatAntWeiboAction:(UIButton *)sender {
...@@ -53,28 +54,37 @@ ...@@ -53,28 +54,37 @@
NSString *goodsID = [self.goodsIds substringToIndex:[self.goodsIds length]-1]; NSString *goodsID = [self.goodsIds substringToIndex:[self.goodsIds length]-1];
NSDictionary *parameterDict = [NSDictionary dictionaryWithObjectsAndKeys:[goodsID substringToIndex:self.goodsIds.length-1],@"goodsIds",@"",@"title",@"",@"remark",nil]; NSDictionary *parameterDict = [NSDictionary dictionaryWithObjectsAndKeys:[goodsID substringToIndex:self.goodsIds.length-1],@"goodsIds",@"",@"title",@"",@"remark",nil];
//上传图片 //上传图片
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:SHARED_APPDELEGATE.window animated:YES];
hud.mode = MBProgressHUDModeDeterminate;
hud.labelText = @"上传中....";
hud.removeFromSuperViewOnHide = YES;
[[NetworkRequestClassManager Manager] UploadImageWithURL:SERVERREQUESTURL(SHARE) WithRequestType:ZERO WithImageDatas:imageData WithParameter:parameterDict WithReturnValueBlock:^(id returnValue) { [[NetworkRequestClassManager Manager] UploadImageWithURL:SERVERREQUESTURL(SHARE) WithRequestType:ZERO WithImageDatas:imageData WithParameter:parameterDict WithReturnValueBlock:^(id returnValue) {
if ([returnValue[@"code"] isEqualToNumber:@0]) { if ([returnValue[@"code"] isEqualToNumber:@0]) {
NSString *shareWeb = returnValue[@"data"][@"url"]; NSString *shareWeb = returnValue[@"data"][@"url"];
[weakSelf callSharePlatform:shareWeb withPlatformTag:sender withTitle:ShareTitle]; [self callSharePlatform:shareWeb withPlatformTag:sender withTitle:ShareTitle];
}else }else
{ {
[weakSelf ErrorMBProgressView:returnValue[@"message"]]; [weakSelf ErrorMBProgressView:returnValue[@"message"]];
} }
}WithprogressBlock:^(double progress) { }WithprogressBlock:^(double progress) {
if (progress >= 1) { if (progress >= 1) {
weakSelf.TCHud.labelText = @"上传完成"; dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf RemoveMBProgressHUDLoding]; [hud hide:YES];
});
}else{ }else{
[weakSelf ShowProgressView:progress]; dispatch_async(dispatch_get_main_queue(), ^{
hud.progress = progress;
});
} }
} WithErrorCodeBlock:^(id errorCodeValue) { } WithErrorCodeBlock:^(id errorCodeValue) {
[weakSelf ErrorMBProgressView:NETWORK]; [hud hide:YES];
} WithFailureBlock:^(NSError *error) { } WithFailureBlock:^(NSError *error) {
weakSelf.TCHud.labelText = @"上传失败"; dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf ErrorMBProgressView:error.localizedDescription]; hud.labelText = @"上传失败";
[hud hide:YES afterDelay:1];
});
}]; }];
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment