//
|
// PBAddPanoramaViewController.m
|
// IphoneBIMe
|
//
|
// Created by ZhangJF on 2022/10/19.
|
// Copyright © 2022 ProBIM. All rights reserved.
|
//
|
|
#import "PBAddPanoramaViewController.h"
|
#import "PBProjectModel.h"
|
#import "PBViewPointScrollView.h"
|
#import "PBChooseType.h"
|
#import "PBPanoramaModel.h"
|
#import "PBViewPointModel.h"
|
#import "PBModelsModel.h"
|
#import "HJCycleView.h"
|
|
static NSString *const ImageCellID = @"ImageCellID";
|
@interface PBAddPanoramaViewController ()<UITextFieldDelegate, LFImagePickerControllerDelegate>
|
@property (nonatomic, strong) PBChooseType *chooseTypeView;
|
@property (nonatomic, strong) NSDictionary *tagDict;
|
@property (nonatomic, weak) UIButton *tagBtn;
|
@property (nonatomic, strong) NSData *imageDate;
|
@property (nonatomic, copy) NSString *imageExtension;
|
@property (nonatomic, weak) UIImageView *panoramaImageV;
|
@property (nonatomic, weak) PBViewPointScrollView *vpScrollView;
|
@property (nonatomic, weak)UITextField *nameTF;
|
@property (nonatomic, weak)UITextField *panoramaNameTF;
|
@property (nonatomic, assign) BOOL isAddsubset;
|
@property (nonatomic, weak) HJCycleView *cycleview;
|
@end
|
|
@implementation PBAddPanoramaViewController
|
|
- (void)viewDidLoad {
|
[super viewDidLoad];
|
[self setupNav];
|
[self setupUI];
|
if (self.isAddsubset) {
|
[self loadImage];
|
}
|
}
|
- (void)setupNav {
|
self.view.backgroundColor = [UIColor z_colorWithR:247 G:247 B:247];
|
self.title = @"添加全景图";
|
PBBackNavItem *backNav = [PBBackNavItem backNacItem];
|
backNav.title = @" ";
|
[backNav addTarget:self action:@selector(backItemAction) forControlEvents:UIControlEventTouchUpInside];
|
UIBarButtonItem *backNavItem = [[UIBarButtonItem alloc] initWithCustomView:backNav];
|
self.navigationItem.leftBarButtonItem = backNavItem;
|
UIBarButtonItem *saveItem = [[UIBarButtonItem alloc] initWithTitle:@"保存" style:UIBarButtonItemStylePlain target:self action:@selector(saveAction)];
|
self.navigationItem.rightBarButtonItem = saveItem;
|
}
|
- (void)loadImage {
|
[YJProgressHUD showProgress:@"正在加载辅助图片..." inView:self.view];
|
NSString *labelId = @"";
|
if (self.isAddsubset) {
|
labelId = self.panoramaModel.LabelId;
|
} else {
|
labelId = [self.tagDict valueForKey:@"LabelId"];
|
}
|
[[PBNetworkTools sharedTools] GetLabelFileWithOrganizeId:self.projectModel.organizeid andLabelId:labelId AndCallBack:^(NSURLSessionDataTask *task, id response, NSError *error) {
|
if (error) {
|
[YJProgressHUD showFailed:@"加载辅助图片失败" inview:self.view];
|
return;
|
}
|
NSString *str = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
|
PBNetworkModel *networkModel = [PBNetworkModel yy_modelWithJSON:str];
|
if (networkModel.Ret == 1) {
|
[YJProgressHUD hide];
|
NSMutableArray *imageM = [[NSMutableArray alloc] init];
|
for (NSDictionary *obj in networkModel.Data) {
|
NSString *url = [NSString stringWithFormat:@"%@/%@", PanoramaUrl, [obj valueForKey:@"FilePath"]];
|
[imageM addObject:url];
|
}
|
self.cycleview.data = imageM.copy;
|
}else {
|
[YJProgressHUD showFailed:networkModel.Msg inview:self.view];
|
}
|
}];
|
}
|
- (void)saveAction {
|
if (self.imageDate == nil) {
|
[YJProgressHUD showMessage:@"请选择全景图" inView:self.view];
|
return;
|
}
|
[YJProgressHUD showProgress:@"正在保存..." inView:self.view];
|
PBViewPointModel *vpModel = self.vpScrollView.vpData;
|
NSString *vpStr = nil;
|
if (vpModel.Override) {
|
NSDictionary *dict = [NSString convertTodictionaryOrArr:vpModel.Override];
|
NSString *pos = [dict valueForKey:@"cameraPosition"];
|
NSString *target = [dict valueForKey:@"controlPostion"];
|
NSString *focalOffset = [dict valueForKey:@"focalOffset"];
|
NSDictionary *vpDict = @{
|
@"pos" : pos,
|
@"target" : target,
|
@"focalOffset" : focalOffset
|
};
|
|
vpStr = [NSString convertToJson:vpDict];
|
}
|
|
PBModelsModel *model = self.vpScrollView.modelData;
|
|
NSString *targetPatchGuid = nil;
|
NSString *name = @"";
|
NSString *labelId = @"";
|
if(self.isAddsubset) {
|
targetPatchGuid = self.panoramaModel.PbGuid;
|
}else {
|
name = self.nameTF.text;
|
labelId = [self.tagDict valueForKey:@"LabelId"];
|
if (name == nil || [name isEqualToString:@""]) {
|
[YJProgressHUD showMessage:@"请输入全景图集名称" inView:self.view];
|
return;
|
}
|
if (labelId == nil) {
|
labelId = @"";
|
}
|
}
|
NSString *panoramaName = [NSString stringWithFormat:@"%@.%@", self.panoramaNameTF.text, self.imageExtension];
|
if (panoramaName == nil || [panoramaName isEqualToString:@""]) {
|
[YJProgressHUD showMessage:@"请输入图片名称" inView:self.view];
|
return;
|
}
|
[[PBNetworkTools sharedTools] UploadPanoramaImagesWithFile:self.imageDate andfileName:panoramaName andTargetPatchGuid:targetPatchGuid andOrganizeId:self.projectModel.organizeid andPbname:name andLabelId:labelId andModelId:model.ID andViewId:vpStr andCallBack:^(NSURLSessionDataTask *task, id response, NSError *error) {
|
if (error) {
|
[YJProgressHUD showFailed:@"保存失败" inview:self.view];
|
return;
|
}
|
NSString *str = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
|
PBNetworkModel *networkModel = [PBNetworkModel yy_modelWithJSON:str];
|
if (networkModel.Ret == 1){
|
[YJProgressHUD hide];
|
if (self.SaveSuccessBlock) {
|
self.SaveSuccessBlock();
|
}
|
[self.navigationController popViewControllerAnimated:YES];
|
}else {
|
[YJProgressHUD showFailed:networkModel.Msg inview:self.view];
|
}
|
}];
|
|
}
|
- (void)backItemAction {
|
[self.navigationController popViewControllerAnimated:YES];
|
}
|
- (void)setupUI {
|
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
|
[self.view addSubview:scrollView];
|
scrollView.contentSize = CGSizeMake(self.view.width, 1200);
|
scrollView.backgroundColor = PBColor(248, 248, 248);
|
NSInteger width = self.view.width - 20;
|
|
UIView *topView = [[UIView alloc] init];
|
topView.backgroundColor = [UIColor whiteColor];
|
[scrollView addSubview:topView];
|
[topView mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.left.equalTo(scrollView).offset(10);
|
make.height.equalTo(@436);
|
make.width.equalTo(@(width));
|
}];
|
[topView circleViewWithRadius:6];
|
|
UIImageView *iconImagV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"add_panorama"]];
|
[topView addSubview:iconImagV];
|
[iconImagV mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(topView).offset(13);
|
make.left.equalTo(topView).offset(10);
|
make.size.mas_equalTo(CGSizeMake(15, 15));
|
}];
|
UILabel *addTitleL = [UILabel z_labelWithText:@"添加全景图" Color:[UIColor z_colorWithR:24 G:24 B:24] isBold:YES Font:15];
|
[topView addSubview:addTitleL];
|
[addTitleL mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(topView).offset(10);
|
make.left.equalTo(iconImagV.mas_right).offset(10);
|
make.height.equalTo(@21);
|
}];
|
UIView *bgV = [[UIView alloc] init];
|
bgV.layer.cornerRadius = 6;
|
bgV.layer.borderWidth = 1;
|
bgV.layer.borderColor = [UIColor z_colorWithR:216 G:216 B:216].CGColor;
|
[topView addSubview:bgV];
|
[bgV mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(iconImagV.mas_bottom).offset(13);
|
make.left.equalTo(iconImagV);
|
make.right.equalTo(topView).offset(-10);
|
make.height.equalTo(@40);
|
}];
|
UILabel *nameL = [UILabel z_labelWithText:@"图集名称" Color:[UIColor z_colorWithR:24 G:24 B:24] isBold:YES Font:13];
|
[bgV addSubview:nameL];
|
[nameL mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.left.equalTo(bgV).offset(10);
|
make.top.equalTo(bgV).offset(11);
|
make.height.equalTo(@19);
|
}];
|
UIView *line = [[UIView alloc] init];
|
line.backgroundColor = [UIColor z_colorWithR:216 G:216 B:216];
|
[bgV addSubview:line];
|
[line mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(bgV).offset(10);
|
make.bottom.equalTo(bgV).offset(-10);
|
make.width.equalTo(@1);
|
make.left.equalTo(bgV).offset(72);
|
}];
|
UITextField *nameTF = [[UITextField alloc] init];
|
nameTF.placeholder = @"请输入全景图集名称";
|
nameTF.textAlignment= NSTextAlignmentLeft;
|
nameTF.textColor = TitleColor;
|
nameTF.font = [UIFont fontWithName:Coarse size:13.0];
|
nameTF.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
|
nameTF.delegate = self;
|
[bgV addSubview:nameTF];
|
[nameTF mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.bottom.equalTo(bgV);
|
make.right.equalTo(bgV).offset(-12);
|
make.left.equalTo(line).offset(10);
|
}];
|
|
|
UIView *bg1V = [[UIView alloc] init];
|
bg1V.layer.cornerRadius = 6;
|
bg1V.layer.borderWidth = 1;
|
bg1V.layer.borderColor = [UIColor z_colorWithR:216 G:216 B:216].CGColor;
|
[topView addSubview:bg1V];
|
[bg1V mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(bgV.mas_bottom).offset(10);
|
make.left.equalTo(iconImagV);
|
make.right.equalTo(topView).offset(-10);
|
make.height.equalTo(@40);
|
}];
|
UILabel *tagL = [UILabel z_labelWithText:@"标签" Color:[UIColor z_colorWithR:24 G:24 B:24] isBold:YES Font:13];
|
[bg1V addSubview:tagL];
|
[tagL mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.left.equalTo(bg1V).offset(10);
|
make.top.equalTo(bg1V).offset(11);
|
make.height.equalTo(@19);
|
}];
|
UIView *line1 = [[UIView alloc] init];
|
line1.backgroundColor = [UIColor z_colorWithR:216 G:216 B:216];
|
[bg1V addSubview:line1];
|
[line1 mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(bg1V).offset(10);
|
make.bottom.equalTo(bg1V).offset(-10);
|
make.width.equalTo(@1);
|
make.left.equalTo(bg1V).offset(72);
|
}];
|
|
|
UIButton *tagBtn = [UIButton z_textButton:@"请选择标签" fontSize:13 normalColor:[UIColor z_colorWithR:102 G:102 B:102]];
|
[tagBtn addTarget:self action:@selector(chooseTag) forControlEvents:UIControlEventTouchUpInside];
|
tagBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
|
[bg1V addSubview:tagBtn];
|
[tagBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.bottom.equalTo(bg1V);
|
make.right.equalTo(bg1V).offset(-12);
|
make.left.equalTo(line1).offset(10);
|
}];
|
|
UIView *addImageView = [[UIView alloc] init];
|
[topView addSubview:addImageView];
|
[addImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(bg1V.mas_bottom).offset(10);
|
make.left.right.equalTo(bgV);
|
make.height.equalTo(@235);
|
}];
|
|
UIImageView *addImagebg = [[UIImageView alloc] init];
|
addImagebg.image = [UIImage imageNamed:@"add_panorama_bg"];
|
[addImageView addSubview:addImagebg];
|
[addImagebg mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.bottom.left.right.equalTo(addImageView);
|
}];
|
|
UIView *btnView = [[UIView alloc] init];
|
[addImageView addSubview:btnView];
|
[btnView mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.center.equalTo(addImageView);
|
make.size.mas_equalTo(CGSizeMake(105, 20));
|
}];
|
UIButton *addImage = [UIButton z_bgImageButton:[UIImage imageNamed:@"panorama_add"]];
|
[addImage addTarget:self action:@selector(addImageAction) forControlEvents:UIControlEventTouchUpInside];
|
[btnView addSubview:addImage];
|
[addImage mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.left.equalTo(btnView);
|
make.size.mas_equalTo(CGSizeMake(20, 20));
|
}];
|
UIButton *addTitle = [UIButton z_textButton:@"上传一张全景图" fontSize:13 normalColor:[UIColor z_colorWithR:0 G:122 B:255]];
|
[addTitle addTarget:self action:@selector(addImageAction) forControlEvents:UIControlEventTouchUpInside];
|
[btnView addSubview:addTitle];
|
[addTitle mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.left.equalTo(addImage.mas_right).offset(4);
|
make.top.bottom.equalTo(btnView);
|
}];
|
|
UIImageView *panoramaImageV = [[UIImageView alloc] init];
|
panoramaImageV.userInteractionEnabled = YES;
|
[addImageView addSubview:panoramaImageV];
|
[panoramaImageV mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.bottom.left.right.equalTo(addImageView);
|
}];
|
[panoramaImageV circleViewWithRadius:6];
|
panoramaImageV.hidden = YES;
|
|
UIButton *deleteBtn = [UIButton z_bgImageButton:[UIImage imageNamed:@"delete_task"]];
|
[deleteBtn addTarget:self action:@selector(deleteImage) forControlEvents:UIControlEventTouchUpInside];
|
[panoramaImageV addSubview:deleteBtn];
|
[deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(panoramaImageV).offset(4);
|
make.right.equalTo(panoramaImageV).offset(-4);
|
make.size.mas_equalTo(CGSizeMake(24, 24));
|
}];
|
|
UIView *namebgV = [[UIView alloc] init];
|
namebgV.layer.cornerRadius = 6;
|
namebgV.layer.borderWidth = 1;
|
namebgV.layer.borderColor = [UIColor z_colorWithR:216 G:216 B:216].CGColor;
|
[topView addSubview:namebgV];
|
[namebgV mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(addImageView.mas_bottom).offset(10);
|
make.left.equalTo(iconImagV);
|
make.right.equalTo(topView).offset(-10);
|
make.height.equalTo(@40);
|
}];
|
UILabel *panoramaNameL = [UILabel z_labelWithText:@"图片名称" Color:[UIColor z_colorWithR:24 G:24 B:24] isBold:YES Font:13];
|
[namebgV addSubview:panoramaNameL];
|
[panoramaNameL mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.left.equalTo(namebgV).offset(10);
|
make.top.equalTo(namebgV).offset(11);
|
make.height.equalTo(@19);
|
}];
|
UIView *line2 = [[UIView alloc] init];
|
line2.backgroundColor = [UIColor z_colorWithR:216 G:216 B:216];
|
[namebgV addSubview:line2];
|
[line2 mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(namebgV).offset(10);
|
make.bottom.equalTo(namebgV).offset(-10);
|
make.width.equalTo(@1);
|
make.left.equalTo(namebgV).offset(72);
|
}];
|
UITextField *panoramaNameTF = [[UITextField alloc] init];
|
panoramaNameTF.placeholder = @"图片名称";
|
panoramaNameTF.textAlignment= NSTextAlignmentLeft;
|
panoramaNameTF.textColor = TitleColor;
|
panoramaNameTF.font = [UIFont fontWithName:Coarse size:13.0];
|
panoramaNameTF.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
|
panoramaNameTF.delegate = self;
|
[namebgV addSubview:panoramaNameTF];
|
[panoramaNameTF mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.bottom.equalTo(namebgV);
|
make.right.equalTo(namebgV).offset(-12);
|
make.left.equalTo(line2).offset(10);
|
}];
|
|
|
UIView *middleView = [[UIView alloc] init];
|
middleView.backgroundColor = [UIColor whiteColor];
|
[scrollView addSubview:middleView];
|
[middleView mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(topView.mas_bottom).offset(10);
|
make.left.width.equalTo(topView);
|
make.height.equalTo(@350);
|
}];
|
[middleView circleViewWithRadius:6];
|
UIImageView *vpiconImagV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"add_viewpoint"]];
|
[middleView addSubview:vpiconImagV];
|
[vpiconImagV mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(middleView).offset(13);
|
make.left.equalTo(middleView).offset(10);
|
make.size.mas_equalTo(CGSizeMake(15, 15));
|
}];
|
UILabel *chooseVpL = [UILabel z_labelWithText:@"选择视点" Color:[UIColor z_colorWithR:24 G:24 B:24] isBold:YES Font:15];
|
[middleView addSubview:chooseVpL];
|
[chooseVpL mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(middleView).offset(10);
|
make.left.equalTo(vpiconImagV.mas_right).offset(10);
|
make.height.equalTo(@21);
|
}];
|
PBViewPointScrollView *vpscrollView = [[PBViewPointScrollView alloc] initWithFrame:CGRectMake(0, 31, width, 319) withProjectModel:self.projectModel];
|
[middleView addSubview:vpscrollView];
|
|
|
UIView *bottomView = [[UIView alloc] init];
|
bottomView.backgroundColor = [UIColor whiteColor];
|
[scrollView addSubview:bottomView];
|
[bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(middleView.mas_bottom).offset(10);
|
make.left.width.equalTo(topView);
|
make.height.equalTo(@286);
|
}];
|
[bottomView circleViewWithRadius:6];
|
|
UIImageView *choosedianImagV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"add_selection"]];
|
[bottomView addSubview:choosedianImagV];
|
[choosedianImagV mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(bottomView).offset(13);
|
make.left.equalTo(bottomView).offset(10);
|
make.size.mas_equalTo(CGSizeMake(15, 15));
|
}];
|
UILabel *choosedianL = [UILabel z_labelWithText:@"辅助选点" Color:[UIColor z_colorWithR:24 G:24 B:24] isBold:YES Font:15];
|
[bottomView addSubview:choosedianL];
|
[choosedianL mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(bottomView).offset(10);
|
make.left.equalTo(choosedianImagV.mas_right).offset(10);
|
make.height.equalTo(@21);
|
}];
|
|
NSInteger collectionW = width - 20;
|
NSInteger collectionH = 286 - 50;
|
|
HJCycleView *cycleview = [[HJCycleView alloc] initWithFrame:CGRectMake(10, 40, collectionW, collectionH) andData:@[]];
|
cycleview.backgroundColor = [UIColor whiteColor];
|
cycleview.returnBlock = ^(NSInteger index) {
|
NSLog(@"点击了%ld",index);
|
};
|
[bottomView addSubview:cycleview];
|
self.cycleview = cycleview;
|
|
|
self.tagBtn = tagBtn;
|
self.panoramaImageV = panoramaImageV;
|
self.vpScrollView = vpscrollView;
|
self.nameTF = nameTF;
|
self.panoramaNameTF = panoramaNameTF;
|
if (_isAddsubset) {
|
self.nameTF.text = self.panoramaModel.PbName;
|
self.nameTF.enabled = NO;
|
[self.tagBtn setTitle:self.panoramaModel.LabelName forState:UIControlStateNormal];
|
}
|
}
|
// 选择标签
|
- (void)chooseTag {
|
if (self.isAddsubset) {
|
return;
|
}
|
[self.view endEditing:YES];
|
[PBKeyWindow addSubview:self.chooseTypeView];
|
PBPanoramaModel *panoramaModel = [[PBPanoramaModel alloc] init];
|
self.chooseTypeView.panoramaModel = panoramaModel;
|
self.chooseTypeView.dateList = self.tagList;
|
self.chooseTypeView.ChooseCompleteBlock = ^(BOOL isSelsected, NSInteger index){
|
if (isSelsected) {
|
self.tagDict = self.tagList[index];
|
[self.tagBtn setTitle:[self.tagDict valueForKey:@"LabelName"] forState:UIControlStateNormal];
|
[self loadImage];
|
}
|
};
|
[self.chooseTypeView show];
|
}
|
//选择全景图
|
- (void)addImageAction {
|
[self takePhotoLibrary];
|
}
|
|
- (void)takePhotoLibrary {
|
PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus];
|
if (status == PHAuthorizationStatusNotDetermined) {//未作出回应
|
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
|
if(status == PHAuthorizationStatusAuthorized) {
|
dispatch_async(dispatch_get_main_queue(), ^{//用户点击ok
|
[self pushLFImagePickerController];
|
});
|
} else {
|
dispatch_async(dispatch_get_main_queue(), ^{//点击不允许访问
|
NSLog(@"点击不允许访问");
|
});
|
}
|
}];
|
}else if (status == PHAuthorizationStatusRestricted) {//没有被授权访问 可能家长控制
|
|
}else if (status == PHAuthorizationStatusDenied) {//已明确否认相册权限
|
UIAlertController * alertController = [UIAlertController alertControllerWithTitle:@"无法访问相册" message:@"请在iPhone的""设置-隐私-相册""中允许访问相册" preferredStyle:UIAlertControllerStyleAlert];
|
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
|
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"设置" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
if (@available(iOS 10.0, *)) {
|
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
|
} else {
|
NSLog(@"选择取消");
|
}
|
}];
|
[alertController addAction:cancelAction];
|
[alertController addAction:okAction];
|
[self presentViewController:alertController animated:YES completion:nil];
|
}else if (status == PHAuthorizationStatusAuthorized){//有权限访问
|
[self pushLFImagePickerController];
|
}
|
}
|
- (void)pushLFImagePickerController {
|
LFImagePickerController *imagePicker = [[LFImagePickerController alloc] initWithMaxImagesCount:1 delegate:self];
|
// imagePicker.maxVideosCount = 1;
|
// imagePicker.allowTakePicture = YES;//内部显示相机
|
imagePicker.isSelectOriginalPhoto = YES;//是否选择原图
|
// if (self.selectedPhotos.count > 0) {
|
imagePicker.allowPickingType = LFPickingMediaTypePhoto;//用户是否可以选择视频
|
// }else {
|
// imagePicker.allowPickingType = LFPickingMediaTypeALL;//用户是否可以选择视频
|
// }
|
imagePicker.allowPickingOriginalPhoto = NO;//原图按钮将隐藏,用户将不能发送原图
|
imagePicker.maxPhotoBytes = 1024 * 1024 * 100;//最大图片所选字节大小
|
if ([UIDevice currentDevice].systemVersion.floatValue >= 8.0f) {
|
imagePicker.syncAlbum = YES; /** 实时同步相册 */
|
}
|
// imagePicker.selectedAssets = self.selectAssetArr;
|
[self presentViewController:imagePicker animated:YES completion:nil];
|
}
|
#pragma mark - LFImagePickerControllerDelegate
|
|
- (void)lf_imagePickerController:(LFImagePickerController *)picker didFinishPickingResult:(NSArray <LFResultObject /* <LFResultImage/LFResultVideo> */*> *)results {
|
if(results.count > 0) {
|
self.panoramaImageV.hidden = NO;
|
LFResultObject *result = results[0];
|
LFResultImage *resultImage = (LFResultImage *)result;
|
self.panoramaImageV.image = resultImage.thumbnailImage;
|
self.imageDate = resultImage.originalData;
|
self.panoramaNameTF.text = [result.info.name stringByDeletingPathExtension];
|
self.imageExtension = [result.info.name pathExtension];
|
}
|
}
|
|
- (void)deleteImage {
|
self.panoramaImageV.image = nil;
|
self.imageDate = nil;
|
self.panoramaImageV.hidden = YES;
|
self.panoramaNameTF.text = @"";
|
self.imageExtension = @"";
|
}
|
|
#pragma mark - UITextFieldDelegate
|
- (void)textFieldDidEndEditing:(UITextField *)textField{
|
// self.unitText = textField.text;
|
|
}
|
- (void)setPanoramaModel:(PBPanoramaModel *)panoramaModel {
|
_panoramaModel = panoramaModel;
|
_isAddsubset = YES;
|
}
|
- (void)setProjectModel:(PBProjectModel *)projectModel {
|
_projectModel = projectModel;
|
}
|
- (void)setTagList:(NSArray *)tagList {
|
_tagList = tagList;
|
}
|
- (PBChooseType *)chooseTypeView {
|
if (_chooseTypeView == nil) {
|
_chooseTypeView = [[PBChooseType alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
_chooseTypeView.visualViewHeight = 300;
|
}
|
return _chooseTypeView;;
|
}
|
|
/*
|
#pragma mark - Navigation
|
|
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
// Get the new view controller using [segue destinationViewController].
|
// Pass the selected object to the new view controller.
|
}
|
*/
|
|
@end
|