123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568 |
- //
- // MusicRoomDetailViewController.m
- // KulexiuForStudent
- //
- // Created by 王智 on 2022/6/27.
- //
- #import "MusicRoomDetailViewController.h"
- #import "AccompanyArrangeCell.h"
- #import "AccompanyHomeworkCell.h"
- #import "AccompanyRemarkCell.h"
- #import "AccompanyDetailBottomView.h"
- #import "HomeworkDetailModel.h"
- #import "EvaluateDetailModel.h"
- #import "KSChatConversationViewController.h"
- #import "KSGroupConversationController.h"
- #import <WMPlayer.h>
- #import <RecordCheckManager.h>
- #import "KSPremissionAlert.h"
- #import "KSMediaManager.h"
- #import "OnlineClassManager.h"
- #import "MusicRoomCourseInfoCell.h"
- #import "HomeworkDetailViewController.h"
- @interface MusicRoomDetailViewController ()<UITableViewDelegate,UITableViewDataSource,WMPlayerDelegate>
- {
- WMPlayer *_wmPlayer;
- CGRect _playerFrame;
- }
- @property (nonatomic, strong) UIView *bgView;
- @property (nonatomic, assign) BOOL isRatation;
- @property (nonatomic, strong) UITableView *tableView;
- @property (nonatomic, strong) NSMutableArray *fileArray;
- @property (nonatomic, strong) KSMediaManager *mediaManager;
- @property (nonatomic, strong) HomeworkDetailModel *homeworkModel;
- @property (strong, nonatomic) MBProgressHUD *HUD;
- @property (nonatomic, strong) AccompanyDetailBottomView *bottomView;
- @property (nonatomic, strong) OnlineClassManager *classManager;
- @property (nonatomic, assign) BOOL canModify;
- @property (nonatomic, assign) BOOL isModify; // 是否修改作业
- @end
- @implementation MusicRoomDetailViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- [self allocTitle:@"课程详情"];
- [self configUI];
- self.isModify = NO;
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [self requestCourseInfoMessage];
- }
- - (void)requestCourseInfoMessage {
- [self requestHomeworkMessage];
- [self requestRoomConfig];
- }
- - (void)requestRoomConfig {
- [KSNetworkingManager selectRoomConfigRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
- if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
- NSDictionary *result = [dic ks_dictionaryValueForKey:@"data"];
- self.joinRoomBeforeTime = [result ks_integerValueForKey:@"pianoStartTime"];
- self.quitRomeEndTime = [result ks_integerValueForKey:@"pianoEndTime"];
- }
- else {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
-
- }];
- }
- - (void)requestHomeworkMessage {
- [LOADING_MANAGER showHUD];
- [KSNetworkingManager homeworkDetailRequest:KS_GET courseId:self.courseId success:^(NSDictionary * _Nonnull dic) {
- [LOADING_MANAGER removeHUD];
- if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
- self.homeworkModel = [[HomeworkDetailModel alloc] initWithDictionary:[dic ks_dictionaryValueForKey:@"data"]];
- if (self.homeworkModel.submitHomework == 1) {
- if (![NSString isEmptyString:self.homeworkModel.studentAttachments]) {
- self.fileArray = [NSMutableArray arrayWithArray:[self.homeworkModel.studentAttachments componentsSeparatedByString:@","]];
- }
- else {
- self.fileArray = [NSMutableArray array];
- }
- }
- else {
- self.fileArray = [NSMutableArray array];
- }
- }
- else {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
- }
- [self evaluateViewDisplay];
- [self.tableView reloadData];
- } faliure:^(NSError * _Nonnull error) {
- [LOADING_MANAGER removeHUD];
- }];
- }
- - (void)evaluateViewDisplay {
- // 老师布置过作业且没有点评 可以点击
- if (self.homeworkModel.reviewHomework == 1 || self.homeworkModel.decorateHomework == 0) {
- self.canModify = NO;
- }
- else {
- self.canModify = YES;
- }
- if ([self.homeworkModel.courseStatus isEqualToString:@"COMPLETE"]) {
- self.bottomView.hidden = YES;
- UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KPortraitWidth, 15)];
- self.tableView.tableFooterView = bottomView;
- }
- else {
- CGFloat bottomHeight = [AccompanyDetailBottomView getViewHeight];
- UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KPortraitWidth, bottomHeight)];
- self.tableView.tableFooterView = bottomView;
-
- self.bottomView.hidden = NO;
- self.bottomView.actionButton.userInteractionEnabled = YES;
- [self.bottomView.actionButton setTitle:@"进入教室" forState:UIControlStateNormal];
- [self.bottomView.actionButton setBackgroundColor:THEMECOLOR];
- [self.bottomView.actionButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- }
- }
- - (void)configUI {
- [self.scrollView removeFromSuperview];
- [self.view addSubview:self.tableView];
- [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.view);
- make.top.mas_equalTo(self.view.mas_top);
- make.bottom.mas_equalTo(self.view.mas_bottom);
- }];
-
- CGFloat bottomHeight = [AccompanyDetailBottomView getViewHeight];
-
- [self.view addSubview:self.bottomView];
- [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.mas_equalTo(self.view);
- make.height.mas_equalTo(bottomHeight);
- }];
- self.bottomView.hidden = YES;
- }
- - (void)evaluateWithStatusLabel:(UILabel *)statusLabel {
- if ([self.homeworkModel.courseStatus isEqualToString:@"COMPLETE"]) {
- statusLabel.text = @"已结束";
- statusLabel.textColor = HexRGB(0x999999);
- }
- else if ([self.homeworkModel.courseStatus isEqualToString:@"ING"]) {
- statusLabel.text = @"进行中";
- statusLabel.textColor = THEMECOLOR;
- }
- else {
- statusLabel.text = @"未开始";
- statusLabel.textColor = HexRGB(0xff802c);
- }
- }
- #pragma mark --- table data source
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return 4;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- if (indexPath.row == 0) {
- MusicRoomCourseInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MusicRoomCourseInfoCell"];
- [self evaluateWithStatusLabel:cell.statusLabel];
- NSString *courseName = [NSString returnNoNullStringWithString:self.homeworkModel.courseGroupName];
- [cell configWithStartTime:self.homeworkModel.startTime endTime:self.homeworkModel.endTime courseName:courseName chatGroupId:self.homeworkModel.imGroupId courseSubject:self.homeworkModel.subjectName];
- MJWeakSelf;
- [cell chatCalkback:^(NSString * _Nonnull targetId) {
- [weakSelf chatAction:targetId];
- }];
- return cell;
- }
- else if (indexPath.row == 1) {
- AccompanyArrangeCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyArrangeCell"];
- BOOL hasArrange = self.homeworkModel.decorateHomework == 1 ? YES : NO;
- [cell configWithHomeworkContent:self.homeworkModel.content hasArrangeHomework:hasArrange];
- return cell;
- }
- else if (indexPath.row == 2) {
- // studentAttachments
- BOOL canDisplay = self.homeworkModel.decorateHomework == 1 ? YES : NO;
- BOOL isExpired = self.homeworkModel.homeworkExpire == 1 ? YES : NO;
- AccompanyHomeworkCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyHomeworkCell"];
- cell.canSubmit = NO;
- cell.showSubmitButton = self.canModify;
- MJWeakSelf;
- [cell configWithAttachmentArray:self.fileArray canDisplaySubmitView:canDisplay isExpired:isExpired callback:^(HOMEWORKACTION action, NSInteger viewIndex) {
- [weakSelf operationActionWithType:action index:viewIndex];
- }];
-
- return cell;
- }
- else {
- AccompanyRemarkCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyRemarkCell"];
- BOOL hasEvaluate = self.homeworkModel.reviewHomework == 1? YES : NO;
- [cell configWithRemarkMessage:self.homeworkModel.teacherReplied hasEvaluate:hasEvaluate];
- return cell;
- }
- }
- - (void)chatAction:(NSString *)targetId {
- if ([NSString isEmptyString:targetId]) {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"报名未结束,暂无群组"];
- return;
- }
- TUIChatConversationModel *model = [[TUIChatConversationModel alloc] init];
- model.groupID = targetId;
- KSGroupConversationController *ctrl = [[KSGroupConversationController alloc] init];
- ctrl.conversation = model;
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- - (void)operationActionWithType:(HOMEWORKACTION)action index:(NSInteger)viewIndex {
- switch (action) {
- case HOMEWORKACTION_PLAY:
- {
- [self playVideoIndex:viewIndex];
- }
- break;
- case HOMEWORKACTION_DELETE:
- {
- [self deleteVideoIndex:viewIndex];
- }
- break;
- case HOMEWORKACTION_ADD: // 选择视频作业
- {
- // 调用相册
- self.mediaManager = [[KSMediaManager alloc] init];
- self.mediaManager.mediaType = MEDIATYPE_VIDEO;
- self.mediaManager.maxPhotoNumber = 1;
- self.mediaManager.baseCtrl = self;
- self.mediaManager.needCropImage = NO;
- MJWeakSelf;
- [self.mediaManager noAlertCallback:^(NSString * _Nullable videoUrl, NSMutableArray * _Nullable imageArray, NSMutableArray * _Nullable imageAsset) {
- NSLog(@"%@", videoUrl);
- // 上传视频
- [weakSelf uploadVideoWithUrl:videoUrl];
- }];
- [self.mediaManager pushImagePickerController];
- }
- case HOMEWORKACTION_HOMEWOEKPAGE:
- {
- HomeworkDetailViewController *detalVC = [[HomeworkDetailViewController alloc] init];
- detalVC.courseId = self.courseId;
- MJWeakSelf;
- [detalVC backRefreshAction:^{
- [weakSelf requestCourseInfoMessage];
- }];
- [self.navigationController pushViewController:detalVC animated:YES];
- }
- default:
- break;
- }
- }
- #pragma mark --- 上传视频文件
- - (void)uploadVideoWithUrl:(NSString *)videoUrl {
- [self hudTipWillShow:YES];
-
- NSURL *uploadFileUrl = [NSURL fileURLWithPath:videoUrl];
- NSData *fileData = [NSData dataWithContentsOfURL:uploadFileUrl];
- NSString *suffix = [NSString stringWithFormat:@".%@",[uploadFileUrl pathExtension]];
- [UPLOAD_MANAGER configWithfilePath:@"/homework/"];
- [UPLOAD_MANAGER videoUpload:fileData fileName:@"video" fileSuffix:suffix progress:^(int64_t bytesWritten, int64_t totalBytes) {
- dispatch_main_async_safe(^{
- // 显示进度
- if (self.HUD) {
- self.HUD.progress = bytesWritten / totalBytes;// progress是回调进度
- }
- });
- } successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
- [self hudTipWillShow:NO];
- NSString *fileUrl = [fileUrlArray lastObject];
- self.isModify = YES;
- // 删除文件
- [self removeVideoWithPath:videoUrl];
- [self.fileArray addObject:fileUrl];
- [self.tableView reloadData];
- } faliure:^(NSError * _Nullable error, NSString * _Nullable descMessaeg) {
- [self hudTipWillShow:NO];
- if (![NSString isEmptyString:descMessaeg]) {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:descMessaeg];
- }
- }];
- }
- - (void)removeVideoWithPath:(NSString *)videoUrl {
- NSFileManager *fileMamager = [NSFileManager defaultManager];
- if ([fileMamager fileExistsAtPath:videoUrl]) {
- [fileMamager removeItemAtPath:videoUrl error:nil];
- }
- }
- // 播放
- - (void)playVideoIndex:(NSInteger)index {
- if (self.fileArray.count > index) {
- NSString *fileUrl = self.fileArray[index];
- [self playVideoWithUrl:fileUrl];
- }
- }
- // 删除
- - (void)deleteVideoIndex:(NSInteger)index {
- if (self.fileArray.count > index) {
- [self.fileArray removeObjectAtIndex:index];
- [self.tableView reloadData];
- }
- self.isModify = YES;
- }
- #pragma mark ------ WMPlayer
- - (void)playVideoWithUrl:(NSString *)fileUrl {
- fileUrl = [fileUrl getUrlEndcodeString];
- _playerFrame = CGRectMake(0, iPhoneXSafeTopMargin, kScreenWidth, kScreenHeight - iPhoneXSafeTopMargin - iPhoneXSafeBottomMargin);
- _wmPlayer = [[WMPlayer alloc] initWithFrame:_playerFrame];
- WMPlayerModel *playModel = [[WMPlayerModel alloc] init];
- playModel.videoURL = [NSURL URLWithString:fileUrl];
- _wmPlayer.playerModel = playModel;
- _wmPlayer.delegate = self;
- _bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
- _bgView.backgroundColor = [UIColor blackColor];
- [[UIApplication sharedApplication].keyWindow addSubview:_bgView];
- [[UIApplication sharedApplication].keyWindow addSubview:_wmPlayer];
- [[UIApplication sharedApplication].keyWindow bringSubviewToFront:_wmPlayer];
-
- [_wmPlayer play];
- }
- - (void)wmplayer:(WMPlayer *)wmplayer clickedCloseButton:(UIButton *)backBtn {
- [wmplayer removePlayer];
- [_bgView removeFromSuperview];
- [self setNeedsStatusBarAppearanceUpdate];
- }
- - (void)wmplayer:(WMPlayer *)wmplayer clickedFullScreenButton:(UIButton *)fullScreenBtn {
- self.isRatation = !self.isRatation;
-
- if (self.isRatation) {
- [wmplayer removeFromSuperview];
- [UIView animateWithDuration:1.0f animations:^{
- wmplayer.transform = CGAffineTransformMakeRotation(M_PI_2);
-
- } completion:^(BOOL finished) {
- wmplayer.frame = CGRectMake(0, iPhoneXSafeTopMargin, kScreenWidth, kScreenHeight - iPhoneXSafeTopMargin - iPhoneXSafeBottomMargin);
- [[UIApplication sharedApplication].keyWindow addSubview:wmplayer];
- [[UIApplication sharedApplication].keyWindow bringSubviewToFront:wmplayer];
- }];
- }
- else {
- [wmplayer removeFromSuperview];
-
- [UIView animateWithDuration:1.0f animations:^{
- // 复原
- wmplayer.transform = CGAffineTransformIdentity;
-
- } completion:^(BOOL finished) {
- wmplayer.frame = CGRectMake(0, iPhoneXSafeTopMargin, kScreenWidth, kScreenHeight - iPhoneXSafeTopMargin - iPhoneXSafeBottomMargin);
- [[UIApplication sharedApplication].keyWindow addSubview:wmplayer];
- [[UIApplication sharedApplication].keyWindow bringSubviewToFront:wmplayer];
- }];
- }
- }
- - (void)bottomButtonAction {
- // 判断
- if ([self.homeworkModel.courseStatus isEqualToString:@"COMPLETE"]) { // 判断是否能提交作业
- if (self.fileArray.count == 0 || self.homeworkModel.reviewHomework == 1 || self.homeworkModel.decorateHomework == 0) {
- return;
- }
- else { // 提交作业
- [self submitHomeworkAction];
- }
- }
- else {
- [self tryJoinRoom];
- }
- }
- - (void)submitHomeworkAction {
- if (self.isModify == NO) {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"请先选择视频文件"];
- return;
- }
- if (self.fileArray.count == 0) {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"请选择作业视频"];
- return;
- }
- NSString *attachment = [self.fileArray componentsJoinedByString:@","];
- [LOADING_MANAGER showHUD];
- [KSNetworkingManager homeSubmitAction:KS_POST courseScheduleId:self.courseId attachment:attachment success:^(NSDictionary * _Nonnull dic) {
- [LOADING_MANAGER removeHUD];
- if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"作业提交成功"];
- [self requestCourseInfoMessage];
- self.isModify = NO;
- }
- else {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
- [LOADING_MANAGER removeHUD];
- }];
- }
- #pragma mark --- lazying
- - (OnlineClassManager *)classManager {
- if (!_classManager) {
- _classManager = [[OnlineClassManager alloc] init];
- }
- return _classManager;
- }
- - (AccompanyDetailBottomView *)bottomView {
- if (!_bottomView) {
- _bottomView = [AccompanyDetailBottomView shareInstance];
- MJWeakSelf;
- [_bottomView sureAction:^{
- [weakSelf bottomButtonAction];
- }];
- }
- return _bottomView;
- }
- - (UITableView *)tableView {
- if (!_tableView) {
- _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
- _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- _tableView.backgroundColor = [UIColor clearColor];
- _tableView.delegate = self;
- _tableView.dataSource = self;
- _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _tableView.showsHorizontalScrollIndicator = NO;
- _tableView.showsVerticalScrollIndicator = NO;
- _tableView.rowHeight = UITableViewAutomaticDimension;
- _tableView.estimatedRowHeight = 136.0f;
- [_tableView registerNib:[UINib nibWithNibName:@"MusicRoomCourseInfoCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"MusicRoomCourseInfoCell"];
- [_tableView registerNib:[UINib nibWithNibName:@"AccompanyArrangeCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyArrangeCell"];
- [_tableView registerNib:[UINib nibWithNibName:@"AccompanyHomeworkCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyHomeworkCell"];
- [_tableView registerNib:[UINib nibWithNibName:@"AccompanyRemarkCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyRemarkCell"];
- }
- return _tableView;
- }
- - (void)hudTipWillShow:(BOOL)willShow{
- if (willShow) {
- [self resignFirstResponder];
- UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
- if (!_HUD) {
- _HUD = [MBProgressHUD showHUDAddedTo:keyWindow animated:YES];
- _HUD.removeFromSuperViewOnHide = YES;
- _HUD.mode = MBProgressHUDModeDeterminateHorizontalBar;
- _HUD.label.text = @"正在上传视频文件...";
- _HUD.contentColor = [UIColor whiteColor];
- _HUD.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
- _HUD.bezelView.backgroundColor = HexRGBAlpha(0x000000, 0.8);
- }else{
- _HUD.progress = 0;
- [keyWindow addSubview:_HUD];
- [_HUD showAnimated:YES];
- }
- }else{
- [_HUD hideAnimated:YES];
- }
- }
- - (void)tryJoinRoom {
-
- NSDateFormatter *dateFormatter = [NSObject getDateformatter];
- [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
- NSDate *beginDate = [dateFormatter dateFromString:self.homeworkModel.startTime];
- NSDate *endDate = [dateFormatter dateFromString:self.homeworkModel.endTime];
- NSDate *currentDate = [NSDate date];
- NSTimeInterval beginTimeInterval = [beginDate timeIntervalSinceDate:currentDate];
- NSTimeInterval endTimeInterval = [currentDate timeIntervalSinceDate:endDate];
- if (beginTimeInterval <= self.joinRoomBeforeTime * 60 && endTimeInterval < 0) {
- [self joinClassRoom];
- }
- else if (endTimeInterval > 0) {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"该课程已结束"];
- }
- else {
- NSString *tipsString = [NSString stringWithFormat:@"课程还未开始,请在上课前%zd分钟进入", self.joinRoomBeforeTime];
- [LOADING_MANAGER MBShowAUTOHidingInWindow:tipsString];
- }
- }
- // 加入房间
- - (void)joinClassRoom {
- // 加入房间前判断摄像头和麦克风逻辑
- [RecordCheckManager checkCameraPremissionAvaiableCallback:^(PREMISSIONTYPE type) {
- [self afterCheckCameraCheckMic:type];
- }];
- }
- - (void)afterCheckCameraCheckMic:(PREMISSIONTYPE)cameraType {
- [RecordCheckManager checkMicPermissionAvaiableCallback:^(PREMISSIONTYPE type) {
- if (type == PREMISSIONTYPE_YES && cameraType == PREMISSIONTYPE_YES) {
- // 判断是否进行课前检测
- [self.classManager joinRoomWithId:self.courseId subjectName:self.homeworkModel.subjectName classEndTime:self.homeworkModel.endTime inViewController:self];
- }
- else {
- NSString *content = @"";
- CHECKDEVICETYPE checkType = CHECKDEVICETYPE_BOTH;
- if (cameraType == PREMISSIONTYPE_NO && type == PREMISSIONTYPE_NO) {
- content = @"请开启相机和麦克风访问权限";
- checkType = CHECKDEVICETYPE_BOTH;
- }
- else if (cameraType == PREMISSIONTYPE_NO && type == PREMISSIONTYPE_YES) {
- content = @"请开启相机访问权限";
- checkType = CHECKDEVICETYPE_CAMREA;
- }
- else if (cameraType == PREMISSIONTYPE_YES && type == PREMISSIONTYPE_NO) {
- content = @"请开启麦克风访问权限";
- checkType = CHECKDEVICETYPE_MIC;
- }
- [self showAlertWithMessage:content type:checkType];
- }
- }];
-
- }
- - (void)showAlertWithMessage:(NSString *)message type:(CHECKDEVICETYPE)deviceType {
- [KSPremissionAlert shareInstanceDisplayImage:deviceType message:message showInView:self.view cancel:^{
-
- } confirm:^{
- [self openSettingView];
- }];
-
- }
- - (void)openSettingView {
- if (@available(iOS 10, *)) {
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
- } else {
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
- }
- }
- /*
- #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
|