iOS投屏

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

2021-02-01  本文已影响0人  iOS打怪升级
1. 参考 MRDLNA

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

2. wifi 获取失败问题

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

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

参考: 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 -> 本地网络权限:开启

上一篇下一篇

猜你喜欢

热点阅读