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

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

parent 99549096
......@@ -103,7 +103,7 @@
self.addpersonInformationButton.layer.cornerRadius = kCornerRadius;
self.changePersonInformationButton.layer.masksToBounds = YES;
self.changePersonInformationButton.layer.cornerRadius = kCornerRadius;
self.indexPage = 1;
self.indexPage = ONE;
self.customerHeader.userInteractionEnabled = YES;
[self.customerHeader addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(customerHeaderClckAction:)]];
//隐藏更改客户按钮
......@@ -347,45 +347,53 @@
[self ErrorMBProgressView:@"请先设置当前客户"];
return;
}
UIAlertController *alertView = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleAlert];
UIImagePickerController *PcCamera = [[UIImagePickerController alloc]init];
PcCamera.delegate = self;
[DeviceDirectionManager instance].isHorizontal=YES;
__weak typeof(self) weakSelf = self;
[alertView addAction:[UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//拍照
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
[PcCamera setSourceType:UIImagePickerControllerSourceTypeCamera];
PcCamera.allowsEditing = YES;
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf presentViewController:PcCamera animated:YES completion:nil];
});
}
else
{
[weakSelf ErrorMBProgressView:@"相机无法使用"];
}
}]];
[alertView addAction:[UIAlertAction actionWithTitle:@"从相册选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//从相册中选择
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
[PcCamera setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
PcCamera.allowsEditing = YES;
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf presentViewController:PcCamera animated:YES completion:nil];
});
}
else
{
[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];
});
// 判断应用是否有使用相机的权限
if(![BaseViewController determineCameraPermissions]){
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"提示" message:@"请在iPad的“设置-隐私-相机”选项中,允许欧立方访问你的相机" preferredStyle:UIAlertControllerStyleAlert];
[alertVC addAction:[UIAlertAction actionWithTitle:@"知道了" style:UIAlertActionStyleCancel handler:nil]];
[self presentViewController:alertVC animated:YES completion:nil];
}else {
UIAlertController *alertView = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleAlert];
UIImagePickerController *PcCamera = [[UIImagePickerController alloc]init];
PcCamera.delegate = self;
[DeviceDirectionManager instance].isHorizontal=YES;
__weak typeof(self) weakSelf = self;
[alertView addAction:[UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//拍照
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
[PcCamera setSourceType:UIImagePickerControllerSourceTypeCamera];
PcCamera.allowsEditing = YES;
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf presentViewController:PcCamera animated:YES completion:nil];
});
}
else
{
[weakSelf ErrorMBProgressView:@"相机无法使用"];
}
}]];
[alertView addAction:[UIAlertAction actionWithTitle:@"从相册选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//从相册中选择
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
[PcCamera setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
PcCamera.allowsEditing = YES;
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf presentViewController:PcCamera animated:YES completion:nil];
});
}
else
{
[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 -拍照、从相册选择
......
......@@ -254,9 +254,7 @@
// 判断应用是否有使用相机的权限
if(![BaseViewController determineCameraPermissions]){
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"提示" message:@"请在iPad的“设置-隐私-相机”选项中,允许欧立方访问你的相机" preferredStyle:UIAlertControllerStyleAlert];
[alertVC addAction:[UIAlertAction actionWithTitle:@"知道了" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
}]];
[alertVC addAction:[UIAlertAction actionWithTitle:@"知道了" style:UIAlertActionStyleCancel handler:nil]];
[self presentViewController:alertVC animated:YES completion:nil];
}else {
......
......@@ -77,42 +77,50 @@
#pragma mark -用户头像点击
- (void)userHeaderClickAction:(UITapGestureRecognizer *)tap
{
UIAlertController *alertView = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleAlert];
UIImagePickerController *PcCamera = [[UIImagePickerController alloc]init];
PcCamera.delegate = self;
[DeviceDirectionManager instance].isHorizontal=YES;
[alertView addAction:[UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//拍照
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
[PcCamera setSourceType:UIImagePickerControllerSourceTypeCamera];
PcCamera.allowsEditing = YES;
[self presentViewController:PcCamera animated:YES completion:nil];
}
else
{
[DeviceDirectionManager instance].isHorizontal=NO;
[self ErrorMBProgressView:@"相机无法使用"];
}
}]];
[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
{
// 判断应用是否有使用相机的权限
if(![BaseViewController determineCameraPermissions]){
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"提示" message:@"请在iPad的“设置-隐私-相机”选项中,允许欧立方访问你的相机" preferredStyle:UIAlertControllerStyleAlert];
[alertVC addAction:[UIAlertAction actionWithTitle:@"知道了" style:UIAlertActionStyleCancel handler:nil]];
[self presentViewController:alertVC animated:YES completion:nil];
}else{
UIAlertController *alertView = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleAlert];
UIImagePickerController *PcCamera = [[UIImagePickerController alloc]init];
PcCamera.delegate = self;
[DeviceDirectionManager instance].isHorizontal=YES;
[alertView addAction:[UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//拍照
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
[PcCamera setSourceType:UIImagePickerControllerSourceTypeCamera];
PcCamera.allowsEditing = YES;
[self presentViewController:PcCamera animated:YES completion:nil];
}
else
{
[DeviceDirectionManager instance].isHorizontal=NO;
[self ErrorMBProgressView:@"相机无法使用"];
}
}]];
[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;
[self ErrorMBProgressView:@"相册无法打开"];
}
}]];
[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];
}
[alertView dismissViewControllerAnimated:YES completion:nil];
}]];
[self presentViewController:alertView animated:YES completion:nil];
}
}
#pragma mark -拍照、从相册选择
#pragma -mark -UIImagePickerControllerDelegate
......
......@@ -15,7 +15,7 @@
<key>CFBundleName</key>
<string>欧立方</string>
<key>CFBundleShortVersionString</key>
<string>1.2.8</string>
<string>1.2.9</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
......
......@@ -155,7 +155,7 @@
- (void)ShowProgressView:(double)progress
{
dispatch_async(dispatch_get_main_queue(), ^{
self.TCHud.mode = MBProgressHUDModeDeterminateHorizontalBar;
self.TCHud.mode = MBProgressHUDModeDeterminate;
self.TCHud.labelText = @"上传中....";
self.TCHud.labelFont = [UIFont systemFontOfSize:12];
self.TCHud.progress = progress;
......
......@@ -263,7 +263,9 @@
[self ErrorMBProgressView:@"没有选择需要分享的商品"];
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];
//商品id拼接
NSMutableString *goodsID = [[NSMutableString alloc]init];
......@@ -291,43 +293,51 @@
#pragma mark -拍照
- (IBAction)TakingPhotoButtonClickAction:(UIButton *)sender {
sender.selected = YES;
UIAlertController *alertView = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleAlert];
UIImagePickerController *PcCamera = [[UIImagePickerController alloc]init];
PcCamera.delegate = self;
[DeviceDirectionManager instance].isHorizontal=YES;
[alertView addAction:[UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//拍照
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
[PcCamera setSourceType:UIImagePickerControllerSourceTypeCamera];
PcCamera.allowsEditing = YES;
[self presentViewController:PcCamera animated:YES completion:nil];
}
else
{
[self ErrorMBProgressView:@"相机无法使用"];
sender.selected = NO;
}
}]];
[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
{
[self ErrorMBProgressView:@"相册无法打开"];
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];
// 判断应用是否有使用相机的权限
if(![BaseViewController determineCameraPermissions]){
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"提示" message:@"请在iPad的“设置-隐私-相机”选项中,允许欧立方访问你的相机" preferredStyle:UIAlertControllerStyleAlert];
[alertVC addAction:[UIAlertAction actionWithTitle:@"知道了" style:UIAlertActionStyleCancel handler:nil]];
[self presentViewController:alertVC animated:YES completion:nil];
}else{
sender.selected = YES;
UIAlertController *alertView = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleAlert];
UIImagePickerController *PcCamera = [[UIImagePickerController alloc]init];
PcCamera.delegate = self;
[DeviceDirectionManager instance].isHorizontal=YES;
[alertView addAction:[UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//拍照
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
[PcCamera setSourceType:UIImagePickerControllerSourceTypeCamera];
PcCamera.allowsEditing = YES;
[self presentViewController:PcCamera animated:YES completion:nil];
}
else
{
[self ErrorMBProgressView:@"相机无法使用"];
sender.selected = NO;
}
}]];
[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
{
[self ErrorMBProgressView:@"相册无法打开"];
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 -拍照、从相册选择
......
......@@ -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 @@
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
#pragma mark - 压缩图片
- (void)setShareImage:(UIImage *)shareImage
{
_shareImage = [UIImage imageWithData:UIImageJPEGRepresentation(shareImage, 0.2)];
}
#pragma mark -分享
- (IBAction)ShareWeiChatAntWeiboAction:(UIButton *)sender {
......@@ -53,28 +54,37 @@
NSString *goodsID = [self.goodsIds substringToIndex:[self.goodsIds length]-1];
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) {
if ([returnValue[@"code"] isEqualToNumber:@0]) {
NSString *shareWeb = returnValue[@"data"][@"url"];
[weakSelf callSharePlatform:shareWeb withPlatformTag:sender withTitle:ShareTitle];
[self callSharePlatform:shareWeb withPlatformTag:sender withTitle:ShareTitle];
}else
{
[weakSelf ErrorMBProgressView:returnValue[@"message"]];
}
}WithprogressBlock:^(double progress) {
if (progress >= 1) {
weakSelf.TCHud.labelText = @"上传完成";
[weakSelf RemoveMBProgressHUDLoding];
dispatch_async(dispatch_get_main_queue(), ^{
[hud hide:YES];
});
}else{
[weakSelf ShowProgressView:progress];
dispatch_async(dispatch_get_main_queue(), ^{
hud.progress = progress;
});
}
} WithErrorCodeBlock:^(id errorCodeValue) {
[weakSelf ErrorMBProgressView:NETWORK];
[hud hide:YES];
} WithFailureBlock:^(NSError *error) {
weakSelf.TCHud.labelText = @"上传失败";
[weakSelf ErrorMBProgressView:error.localizedDescription];
dispatch_async(dispatch_get_main_queue(), ^{
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