美文网首页iOS投屏
iOS投屏 & wifi 获取2021-02-01

iOS投屏 & wifi 获取2021-02-01

作者: iOS打怪升级 | 来源:发表于2021-02-01 14:20 被阅读0次
1. 参考 MRDLNA

http://www.cocoachina.com/articles/23448

2. wifi 获取失败问题

ios 13 获取wifi 权限更严格了,需要bungdle id 开启wifi 权限 ,plist添加权限声明,并且需要用户允许使用地理位置,否则无法获取wifi 信息

  • 配置开启wifi 权限


    image.png
  • 位置信息权限获取

 if (@available(iOS 13.0, *)){
        if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined ) {
            if (!_locationManager) {
                self.locationManager = [[CLLocationManager alloc] init];
            }
            [self.locationManager requestWhenInUseAuthorization];
        }
    }

  • plist 文件权限声明


    image.png

参考: https://www.jishudog.com/16321/html

3.关于airplay 的UI 修改
 MPVolumeView *volume = [[MPVolumeView alloc] initWithFrame:CGRectMake(5, 10, self.view.frame.size.width, 55)];
    volume.backgroundColor = UIColor.clearColor;
    volume.tag = LB_AirPlayBtnTag;
    volume.showsVolumeSlider = NO;
    [volume sizeToFit];
    self.airPlayButton = volume;
    [volume.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        if ([obj isKindOfClass:[UIButton class]]) {
            UIButton *btn = obj;
            [btn setBackgroundColor:[UIColor clearColor]];
            [btn.titleLabel setTextAlignment:NSTextAlignmentLeft];
            [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            [btn addTarget:self action:@selector(clickDownEvent:) forControlEvents:UIControlEventTouchDown];
            [btn setImage:nil forState:UIControlStateNormal];
            [btn setImage:nil forState:UIControlStateSelected];
            [btn setImage:nil forState:UIControlStateHighlighted];
            btn.frame = CGRectMake(0, 0, self.view.frame.size.width, 30);
            btn.tag = LB_AirPlayBtnTag;
///注意alpha 默认是0 ,需要手动修改,才能正常添加到自己定义的视图上面,我这里是最终添加了uitableviewcell.contentView 上面
            btn.alpha = 1;
            btn.userInteractionEnabled = YES;
 
            *stop = YES;
            
        }
    }];

4.设备搜索不到问题

设备系统<本地网络>授权未开启,在系统设置->你的app -> 本地网络权限:开启

相关文章

网友评论

    本文标题:iOS投屏 & wifi 获取2021-02-01

    本文链接:https://www.haomeiwen.com/subject/tqwjtltx.html