// // MineKankanEditViewController.m // Ifish // // Created by imac on 16/11/9. // Copyright © 2016年 lianxiang. All rights reserved. // #import "MineKankanEditViewController.h" #import "MineKanEditSec0ViewCell.h" #import "MineKanEditSec1firstCell.h" #import "MineKanEditSec1SecondCell.h" #import "MineKanEditSec1ThredCell.h" #import "MineKanEditSec2FirstCell.h" #import "MineKanEditSec2SecCell.h" #import "MineKanEditSec2ThredCell.h" #define CELL_XUANYANTEXTVIEWTAG 240000 #define CELL_LIVEWFACEVIEWTAG 240100 #define CELL_LIVEWNAMETAG 240200 #define CELL_LIVECAMERANAMETAG 240300 #define CELL_LIVESHARETAG 240400 #define CELL_TIJIAOTAG 240500 #import "UITextView+AddKeybordDoneVIew.h" #import "LXActionView.h" #import "IfishCameraModel.h" #import "MineKanKanRoomInfo.h" #define PHOTOSHEET_TAG 1001010 #define DEVICESHEET_TAG 1001110 @interface MineKankanEditViewController () @property(nonatomic,strong)UITableView *tableView; @property(nonatomic,strong)UIActionSheet*photosheet; @property(nonatomic,strong)UIActionSheet*deviceSheet; //@property (nonatomic,copy) NSString *roomName; @property (nonatomic,copy) NSString *camraName; @property (nonatomic,copy) NSString *camraID; @property (nonatomic,copy) NSString *isLive; @property (nonatomic,copy) NSString *roomSatus; @property (nonatomic,strong) NSArray *cameraIdArr; @property (nonatomic,copy) NSString *xuanYan; @property (nonatomic,strong) MineKanKanRoomInfo *roomInfoinfo; @property (nonatomic) BOOL saved; @property(nonatomic) NSTimer *getInfTimer; @end @implementation MineKankanEditViewController - (void)viewDidLoad { [super viewDidLoad]; [self initCameradata]; [self loadData]; // Do any additional setup after loading the view. [self addTitleViewWithTitle:@"我的看看"]; [self creatTab]; _saved = NO; } -(void)goBackAction{ //IOS 8 if (_saved) { [self.navigationController popViewControllerAnimated:YES]; return; } UIAlertController*ac=[UIAlertController alertControllerWithTitle:@"" message:@"是否放弃当前修改" preferredStyle:UIAlertControllerStyleAlert]; [self presentViewController:ac animated:YES completion:nil]; [ac addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction*action){ }]]; [ac addAction:[UIAlertAction actionWithTitle:@"放弃" style:UIAlertActionStyleDefault handler:^(UIAlertAction*action){ [self.navigationController popViewControllerAnimated:YES]; }]]; } -(void)loadData{ //获取直播间信息 UserModel*model=[dataContorl getUserInfo]; NSString *userId =[NSString stringWithFormat:@"%@",model.userId]; [AFHttpTool getLiewRoomInfo:userId success:^(id response) { NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil]; NSDictionary *dataDic=reDic[@"data"]; if ([dataDic isKindOfClass:[NSNull class]]) { return ; } if ([reDic[@"result"] isEqualToString:@"100"]) { MineKanKanRoomInfo *info=[[MineKanKanRoomInfo alloc] init]; if (dataDic.count !=0) { info.createTime = dataDic[@"createTime"]; info.popularityValue = dataDic[@"popularityValue"]; info.roomDesc = dataDic[@"roomDesc"]; info.roomId = dataDic[@"roomId"]; info.roomName = dataDic[@"roomName"]; info.roomStatus = dataDic[@"roomStatus"]; info.userId = dataDic[@"userId"]; self.roomInfoinfo = info; self.isLive = self.roomInfoinfo.roomStatus; if (self.isLive) { if ([self.isLive isEqualToString:@"2"]) { [self heiMingDanAlert]; } } [self.tableView reloadData]; } } } failure:^(NSError *err) { }]; } -(void)heiMingDanAlert{ UIAlertController*ac=[UIAlertController alertControllerWithTitle:@"" message:@"由于您分享的内容不符合规范,您的分享已经被关闭,如需重新开启请联系客服。" preferredStyle:UIAlertControllerStyleAlert]; [self presentViewController:ac animated:YES completion:nil]; [ac addAction:[UIAlertAction actionWithTitle:@"知道了" style:UIAlertActionStyleCancel handler:^(UIAlertAction*action){ [self.navigationController popViewControllerAnimated:YES]; }]]; } -(void)initCameradata{ NSArray*cameraArr =[dataContorl getallCameras]; if ([cameraArr count] !=0) { for (IfishCameraModel *model in cameraArr) { //直播开启 且已激活 if ([model.isLive isEqualToString:@"1"] &&[model.isActive isEqualToString:@"1"]) { self.camraName = model.showName; self.camraID = model.cameraId; } } } if (!self.isLive) { self.isLive = @"0"; } if (!self.camraName) { self.camraName = @"请选择摄像头"; } } -(void)creatTab{ self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height ) style:UITableViewStylePlain]; self.tableView.delegate = self; self.tableView.dataSource = self; self.tableView.scrollEnabled = YES; self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; self.tableView.showsVerticalScrollIndicator = NO; self.tableView.backgroundColor = TABLE_BACKGROUD_COLOR; [self.view addSubview:self.tableView]; } #pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 3; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (section == 0) { return 1; }else if (section == 1){ return 3; }else if (section == 2){ return 3; } return 0; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section ==0) { MineKanEditSec0ViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MineKanEditSec0ViewCell"]; if (!cell) { cell = [[[NSBundle mainBundle]loadNibNamed:@"MineKanEditSec0ViewCell" owner:self options:nil]lastObject]; } cell.tag = CELL_LIVEWFACEVIEWTAG; if (self.roomInfoinfo) { [cell loadImgWith:self.roomInfoinfo]; cell.tianJiaBtn.hidden = YES; cell.tianJiaLabel.hidden= YES; }else{ cell.tianJiaBtn.hidden = NO; cell.tianJiaLabel.hidden= NO; } [cell.tianJiaBtn addTarget:self action:@selector(addImgAction) forControlEvents:UIControlEventTouchUpInside]; cell.selectionStyle = UITableViewCellSelectionStyleNone; return cell; }else if (indexPath.section ==1 && indexPath.row ==0){ MineKanEditSec1firstCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MineKanEditSec1firstCell"]; if (!cell) { cell = [[[NSBundle mainBundle]loadNibNamed:@"MineKanEditSec1firstCell" owner:self options:nil]lastObject]; } if (self.roomInfoinfo.roomName) { cell.roomNameFiled.text = self.roomInfoinfo.roomName; } cell.roomNameFiled.delegate= self; cell.tag = CELL_LIVEWNAMETAG; return cell; }else if (indexPath.section ==1 && indexPath.row ==1){ MineKanEditSec1SecondCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MineKanEditSec1SecondCell"]; if (!cell) { cell = [[[NSBundle mainBundle]loadNibNamed:@"MineKanEditSec1SecondCell" owner:self options:nil]lastObject]; } cell.accessoryType =UITableViewCellAccessoryDisclosureIndicator; cell.tag = CELL_LIVECAMERANAMETAG; //获取当前用户摄像头 选择isLive = 1 的显示 if (self.camraName) { cell.cameraName.text = self.camraName; return cell; } cell.cameraName.text = @"暂无可用摄像头"; return cell; }else if (indexPath.section ==1 && indexPath.row ==2){ MineKanEditSec1ThredCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MineKanEditSec1ThredCell"]; if (!cell) { cell = [[[NSBundle mainBundle]loadNibNamed:@"MineKanEditSec1ThredCell" owner:self options:nil]lastObject]; } cell.tag = CELL_LIVESHARETAG; //直播开启 且已激活 if (!self.isLive) { self.isLive = @"0"; } if ([self.isLive isEqualToString:@"1"]) { cell.shareSwicthBtn.selected = YES; }else{ cell.shareSwicthBtn.selected = NO; } [cell.shareSwicthBtn addTarget:self action:@selector(shareBtnAction:) forControlEvents:UIControlEventTouchUpInside]; return cell; }else if (indexPath.section ==2 && indexPath.row ==0){ MineKanEditSec2FirstCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MineKanEditSec2FirstCell"]; if (!cell) { cell = [[[NSBundle mainBundle]loadNibNamed:@"MineKanEditSec2FirstCell" owner:self options:nil]lastObject]; } return cell; }else if (indexPath.section ==2 && indexPath.row ==1){ MineKanEditSec2SecCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MineKanEditSec2SecCell"]; if (!cell) { cell = [[[NSBundle mainBundle]loadNibNamed:@"MineKanEditSec2SecCell" owner:self options:nil]lastObject]; } cell.tag = CELL_XUANYANTEXTVIEWTAG; cell.xuanYanFiled.delegate= self; //扩展键盘 // [cell.xuanYanFiled keybordViewAddDoneView]; if (self.roomInfoinfo) { cell.xuanYanFiled.text = self.roomInfoinfo.roomDesc; [cell.plachoderlabel setHidden:YES]; } return cell; }else if (indexPath.section ==2 && indexPath.row ==2){ MineKanEditSec2ThredCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MineKanEditSec2ThredCell"]; if (!cell) { cell = [[[NSBundle mainBundle]loadNibNamed:@"MineKanEditSec2ThredCell" owner:self options:nil]lastObject]; } cell.tag = CELL_TIJIAOTAG; [cell.baoCunBtn addTarget:self action:@selector(tijiaoZiLiao:) forControlEvents:UIControlEventTouchUpInside]; cell.selectionStyle = UITableViewCellSelectionStyleNone; return cell; } return nil; } -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ if (section == 0) { return 0; }else{ return 20; } } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section ==0) { return kScreenSize.width * 0.46; }else if (indexPath.section ==1){ return kScreenSize.width*0.12; }else if (indexPath.section ==2 && indexPath.row ==0){ return kScreenSize.width*0.12; }else if (indexPath.section ==2 && indexPath.row ==1){ return kScreenSize.width*0.33; }else if (indexPath.section ==2 && indexPath.row ==2){ return kScreenSize.width*0.26; } return 0; } -(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ UIView*view = nil; if (section!=0) { view= [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenSize.width, 20)]; view.backgroundColor = RGB(242, 242, 242); } return view; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ [tableView deselectRowAtIndexPath:indexPath animated:YES]; MineKanEditSec1firstCell *cell = [self.view viewWithTag:CELL_LIVEWNAMETAG]; [cell.roomNameFiled resignFirstResponder]; MineKanEditSec2SecCell *cell1 = [self.view viewWithTag:CELL_XUANYANTEXTVIEWTAG]; [cell1.xuanYanFiled resignFirstResponder]; if (indexPath.section == 0 && indexPath.section == 0) { [self picImgHandler]; }else if (indexPath.section == 1 && indexPath.row == 0){ }else if (indexPath.section == 1 && indexPath.row == 1){ [self creatActionCameralistViewAt:indexPath]; } } -(void)creatActionCameralistViewAt:(NSIndexPath*)index { NSArray*cameraArr =[dataContorl getallCameras]; NSMutableArray*titles =[[NSMutableArray alloc] init]; NSMutableArray*cameIds =[[NSMutableArray alloc] init]; if (cameraArr.count ==0) { [self.view makeToast:@"暂未绑定摄像头"]; return; } for (IfishCameraModel *camra in cameraArr) { //判断是否激活 if ([camra.isActive isEqualToString:@"1"]) { [titles addObject:camra.showName]; [cameIds addObject:camra.cameraId]; } } if (titles.count==0) { [self.view makeToast:@"暂无可用摄像头"]; return; } LXActionView *sheetView=[[LXActionView alloc] initWithFrame:CGRectMake(0,0,kScreenSize.width,kScreenSize.height)]; [sheetView setOnlytitles:titles]; [sheetView showActionSheet]; sheetView.didSelectedAtIndexPath = ^(NSString *title,NSIndexPath *indexPath) { if (indexPath.row != titles.count +1) { NSLog(@"indexPath%ld",(long)indexPath.row); self.camraName = titles[indexPath.row]; self.camraID = cameIds[indexPath.row]; NSArray *arr=@[index]; [self.tableView reloadRowsAtIndexPaths:arr withRowAnimation:UITableViewRowAnimationNone]; //[self.tableView reloadData]; } }; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -(void)viewWillAppear:(BOOL)animated{ //宣言 //[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wifiviewkeyboradWillShow:) name:UIKeyboardWillChangeFrameNotification object:nil]; //房间名 // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wifiviewkeyboradWillShow:) name:UIKeyboardWillChangeFrameNotification object:nil]; } -(void)viewWillDisappear:(BOOL)animated{ [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil]; } -(void)wifiviewkeyboardWillHide:(NSNotification *)notify{ // 键盘动画时间 double duration = [[notify.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; //视图下沉恢复原状 [UIView animateWithDuration:duration animations:^{ self.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); }]; } -(void)wifiviewkeyboradWillShow:(NSNotification*)notification{ MineKanEditSec2SecCell *cell = [self.view viewWithTag:CELL_XUANYANTEXTVIEWTAG]; CGRect keyboardFrame = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue]; CGRect buttonRect = [cell.xuanYanFiled convertRect:cell.xuanYanFiled.bounds toView:self.view]; CGFloat buttonMargin =(buttonRect.origin.y + buttonRect.size.height + 10); CGFloat transformY = keyboardFrame.origin.y - buttonMargin; // 连贯 double duration = [[notification.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; [UIView animateWithDuration:duration animations:^{ if (keyboardFrame.origin.y < self.view.frame.size.height) { self.view.transform = CGAffineTransformMakeTranslation(0,transformY); }else{ self.view.transform = CGAffineTransformMakeTranslation(0, 0); } }]; } #pragma mar- textField代理 -(BOOL)textFieldShouldBeginEditing:(UITextField *)textField { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textkeyboradWillShow:) name:UIKeyboardWillChangeFrameNotification object:nil]; return YES; } -(void)textkeyboradWillShow:(NSNotification*)notification{ self.view.transform = CGAffineTransformMakeTranslation(0, 0); } #pragma mar- UITextView代理 -(BOOL)textViewShouldBeginEditing:(UITextView *)textView{ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wifiviewkeyboradWillShow:) name:UIKeyboardWillChangeFrameNotification object:nil]; return YES; } -(void)textViewDidEndEditing:(UITextView *)textView{ // self.navigationItem.rightBarButtonItem=nil; [textView resignFirstResponder]; } -(void)picImgHandler{ if (IFISHIOS8) { UIAlertController*alertCT=[UIAlertController alertControllerWithTitle:@"获取图片" message:nil preferredStyle:UIAlertControllerStyleActionSheet]; // 判断是否支持相机 模拟器无相机 if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { UIAlertAction*action=[UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { // 相机 UIImagePickerController *imagePicker=[[UIImagePickerController alloc]init]; imagePicker.delegate=self; imagePicker.allowsEditing=YES; imagePicker.sourceType=UIImagePickerControllerSourceTypeCamera; [self presentViewController:imagePicker animated:YES completion:nil]; }]; [alertCT addAction:action]; } UIAlertAction*action1=[UIAlertAction actionWithTitle:@"从相册选取" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { //相册 UIImagePickerController*imgpic=[[UIImagePickerController alloc]init]; imgpic.delegate=self; imgpic.allowsEditing=YES; imgpic.sourceType=UIImagePickerControllerSourceTypePhotoLibrary; [self presentViewController:imgpic animated:YES completion:nil]; }]; [alertCT addAction:action1]; UIAlertAction *cancelAction=[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { }]; [alertCT addAction:cancelAction]; [self presentViewController:alertCT animated:YES completion:nil]; }else{ if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { self.photosheet=[[UIActionSheet alloc]initWithTitle:@"获取图片" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"拍照",@"从相册选择", nil]; self.photosheet.tag = PHOTOSHEET_TAG; } [self.photosheet showInView:self.view]; } } #pragma mark--UIActionSheetDelegate IOS7 -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{ if (actionSheet.tag == PHOTOSHEET_TAG) { if (actionSheet==self.photosheet) { if (buttonIndex==actionSheet.cancelButtonIndex) { return; } NSUInteger sourceType=0; if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { switch (buttonIndex) { case 0: { sourceType=UIImagePickerControllerSourceTypeCamera; } break; case 1: { sourceType=UIImagePickerControllerSourceTypePhotoLibrary; } break; default: break; } }else{ if (buttonIndex==1) { sourceType=UIImagePickerControllerSourceTypeSavedPhotosAlbum; } } // 转跳页面 UIImagePickerController*imgPic=[[UIImagePickerController alloc]init]; imgPic.delegate=self; imgPic.allowsEditing=YES; imgPic.sourceType=sourceType; [self presentViewController:imgPic animated:YES completion:nil]; } }else if (actionSheet.tag == DEVICESHEET_TAG){ //设备列表 if (buttonIndex==actionSheet.cancelButtonIndex) { return; } } } #pragma mark --选取完成后调用方法 -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ [picker dismissViewControllerAnimated:YES completion:nil] ; UIImage*img=[info objectForKey:UIImagePickerControllerEditedImage]; //UIImage *smallImage = [self scaleFromImage:img toSize:CGSizeMake(kScreenSize.width,kScreenSize.width*2/3)]; UIImage *smallImage = [dataContorl handleImage:img withSize:CGSizeMake(kScreenSize.width, kScreenSize.width*0.46)]; MineKanEditSec0ViewCell *cell = [self.view viewWithTag:CELL_LIVEWFACEVIEWTAG]; cell.liveFaceView.image = smallImage; cell.tianJiaBtn.hidden= YES; cell.tianJiaLabel.hidden = YES; } - (UIImage *) scaleFromImage: (UIImage *) image toSize: (CGSize) size { UIGraphicsBeginImageContext(size); [image drawInRect:CGRectMake(0, 0, size.width, size.height)]; UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return newImage; } - (UIImage *)thumbnailWithImageWithoutScale:(UIImage *)image size:(CGSize)asize { UIImage *newimage; if (nil == image) { newimage = nil; } else{ CGSize oldsize = image.size; CGRect rect; if (asize.width/asize.height > oldsize.width/oldsize.height) { rect.size.width = asize.width*oldsize.height/oldsize.width; // rect.size.height = asize.height*oldsize.height/oldsize.width; rect.size.height = asize.width*oldsize.height/oldsize.width; rect.origin.x = (asize.width - rect.size.width)/2; rect.origin.y = 0; } else{ //rect.size.width = asize.width; rect.size.width = asize.height*oldsize.width/oldsize.height; rect.size.height = asize.height*oldsize.width/oldsize.height; rect.origin.x = 0; rect.origin.y = (asize.height - rect.size.height)/2; } UIGraphicsBeginImageContext(asize); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(context, [[UIColor clearColor] CGColor]); UIRectFill(CGRectMake(0, 0, asize.width, asize.height));//clear background [image drawInRect:rect]; newimage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); } return newimage; } #pragma mark - addImgAction -(void)addImgAction{ [self picImgHandler]; } #pragma mark-shareBtnAction -(void)shareBtnAction:(UIButton*)btn{ NSLog(@"self.isLive%@",self.isLive); btn.selected =!btn.selected; if (btn.selected) { self.isLive = @"1"; }else{ self.isLive = @"0"; } NSLog(@"self.isLive%@",self.isLive); } #pragma mark - tijiaoZiLiao -(void)tijiaoZiLiao:(UIButton *)btn{ if (btn.selected) { return; } btn.selected = YES; //5秒后又可以处理点击事件 防止多次 [self performSelector:@selector(timeEnough) withObject:nil afterDelay:3.0]; NSString *userId =[dataContorl dataControlGetUserIdInfo]; MineKanEditSec2SecCell *cell = [self.view viewWithTag:CELL_XUANYANTEXTVIEWTAG]; MineKanEditSec0ViewCell *cell2 = [self.view viewWithTag:CELL_LIVEWFACEVIEWTAG]; if (!self.camraID) { [self.view makeToast:@"请选择摄像头"]; return; } if ( cell.xuanYanFiled.text.length>70) { [self.view makeToast:@"宣言不能超过70字"]; return; } if ( cell.xuanYanFiled.text.length==0) { [self.view makeToast:@"宣言不能为空"]; return; } if (!cell2.liveFaceView.image) { [self.view makeToast:@"请添加封面"]; return; } MineKanEditSec1firstCell *cell3 = [self.view viewWithTag:CELL_LIVEWNAMETAG]; if (cell3.roomNameFiled.text.length ==0) { [self.view makeToast:@"请给房间起个名字"]; return; } if (cell3.roomNameFiled.text.length >20) { [self.view makeToast:@"房间名不能超过20字"]; return; } if (self.roomInfoinfo) { if (!self.isLive) { self.isLive = @"0"; }else{ if ([self.isLive isEqualToString:@"2"]) { [self.view makeToast:@"由于您分享的内容不符合规范,您的分享已经被关闭,如需重新开启请联系客服。"]; return; } } [self updateLiveRoomWith:self.camraID userId:userId roomId:self.roomInfoinfo.roomId isLive:self.isLive roomName:cell3.roomNameFiled.text roomDesc:cell.xuanYanFiled.text upLoadFile:cell2.liveFaceView.image]; }else{ if (!self.isLive) { self.isLive = @"0"; }else{ if ([self.isLive isEqualToString:@"2"]) { [self.view makeToast:@"由于您分享的内容不符合规范,您的分享已经被关闭,如需重新开启请联系客服。"]; return; } } [self addLiveRoom:self.camraID userId:userId isLive:self.isLive roomName:cell3.roomNameFiled.text roomDesc:cell.xuanYanFiled.text upLoadFile:cell2.liveFaceView.image]; } } -(void)timeEnough { MineKanEditSec2ThredCell *cell =[self.view viewWithTag:CELL_TIJIAOTAG]; cell.baoCunBtn.selected=NO; } #pragma mark- 新增直播间 //islive 为直播间状态 -(void)addLiveRoom:(NSString*)cameaId userId:(NSString*)userId isLive:(NSString *)isLive roomName:(NSString *)roomName roomDesc:(NSString *)roomdesc upLoadFile:(UIImage*)upLoadFile{ [AFHttpTool addLiveRoombyUserId:userId cameraId:cameaId isLive:isLive roomName:roomName roomDec:roomdesc upLoadFile:upLoadFile name:@"fileUpload" success:^(id response) { NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil]; if ([reDic[@"result"] isEqualToString:@"100"]) { [self.view makeToast:@"提交成功"]; _saved = YES; [self saveNewCameraIhfo:reDic]; //开启摄头像加金币 加金币 if (isLive) { if ([isLive isEqualToString:@"1"]) { [[IfishUserObsever sharedInstance] addGoldWith:OPENSHARECAMERA addType:IFISHADDGOLDTYPE1]; } } }else if ([reDic[@"result"] isEqualToString:@"206"]){ [self.view makeToast:@"上传封面不能大于1M"]; } } failure:^(NSError *err) { NSLog(@"self.roomSatus2%@",self.roomSatus); }]; } #pragma mark - 修改直播间信息 -(void)updateLiveRoomWith:(NSString*)cameaId userId:(NSString*)userId roomId:(NSString *)roomId isLive:(NSString *)isLive roomName:(NSString *)roomName roomDesc:(NSString *)roomdesc upLoadFile:(UIImage*)upLoadFile{ [AFHttpTool updateLiveRoomCameraId:cameaId userId:userId roomId:roomId isLive:isLive roomName:roomName roomDesc:roomdesc upLoadFile:upLoadFile name:@"fileUpload" success:^(id response) { NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil]; if ([reDic[@"result"] isEqualToString:@"100"]) { [self saveCameraIhfo:reDic]; _saved = YES; [self.view makeToast:@"提交成功"]; _getInfTimer = [NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(delayDissMiss) userInfo:nil repeats:NO]; //开启摄头像加金币 加金币 if (isLive) { if ([isLive isEqualToString:@"1"]) { [[IfishUserObsever sharedInstance] addGoldWith:OPENSHARECAMERA addType:IFISHADDGOLDTYPE1]; } } }else if ([reDic[@"result"] isEqualToString:@"206"]){ [self.view makeToast:@"上传封面不能大于1M"]; }else if ([reDic[@"result"] isEqualToString:@"214"]){ [self.view makeToast:@"摄像头已经在直播"]; } } failure:^(NSError *err) { }]; } -(void)delayDissMiss{ [_getInfTimer invalidate]; _getInfTimer = nil; [self.navigationController popViewControllerAnimated:YES]; } #pragma mark - 新增 -(void)saveNewCameraIhfo:(NSDictionary *)reDic{ NSDictionary *dic = reDic[@"data"]; NSString *cameraID = nil; NSString *isAlive = nil; cameraID = dic[@"cameraId"]; isAlive = dic[@"isLive"]; //找到对应摄像头修改摄像头isLive 状态 NSArray*cameraArr =[dataContorl getallCameras]; NSMutableArray *newArr=[[NSMutableArray alloc] init]; for (IfishCameraModel *camera in cameraArr) { if ([camera.cameraId isEqualToString:cameraID]) { camera.isLive = isAlive; } [newArr addObject:camera]; } //保存 [dataContorl saveCameraArr:newArr]; } #pragma mark - 修改 -(void)saveCameraIhfo:(NSDictionary *)reDic { NSArray *dicA = reDic[@"data"]; NSString *cameraID = nil; NSString *isAlive = nil; for (NSDictionary *dic in dicA) { cameraID = dic[@"cameraId"]; isAlive = dic[@"isLive"]; } //找到对应摄像头修改摄像头isLive 状态 NSArray*cameraArr =[dataContorl getallCameras]; NSMutableArray *newArr=[[NSMutableArray alloc] init]; for (IfishCameraModel *camera in cameraArr) { if ([camera.cameraId isEqualToString:cameraID]) { camera.isLive = @"1"; }else{ camera.isLive = @"0"; } [newArr addObject:camera]; } //保存 [dataContorl saveCameraArr:newArr]; } #pragma mark--UITextViewDelegate // 设置textView的默认提示文字 -(void)textViewDidChange:(UITextView *)textView{ MineKanEditSec2SecCell *cell = [self.view viewWithTag:CELL_XUANYANTEXTVIEWTAG]; if (textView.text.length ==0) { [cell.plachoderlabel setHidden:NO]; }else{ [cell.plachoderlabel setHidden:YES]; } } @end