IOS13遇到的坑

2019-10-08  本文已影响0人  丸子_8786

1、深色模式更新后页面显示不美观UI还没来得及出方案

解决方法:

强制设置为浅色模式

if(@available(iOS13.0, *)) {

        self.window.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;

    }

2、打包报错 IPA has no main app

1、连接手机更换为13以下手机

2、增加SceneDelegate

3、模态样式改变

原先横竖屏控制是有不同的UINavigationController控制的,由于ios13升级present模态的样式改变不能通过present修改navi的方式控制横竖屏,所有修改为

方式一

-(UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{

    if (self.canDirection) {

        return UIInterfaceOrientationMaskAll;

    }

    return UIInterfaceOrientationMaskPortrait;

}

方式二

- (BOOL)shouldAutorotate

{

    return self.topViewController.shouldAutorotate;

}

-(UIInterfaceOrientationMask)supportedInterfaceOrientations

{

    return self.topViewController.supportedInterfaceOrientations;

}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation

{

    return self.topViewController.preferredInterfaceOrientationForPresentation;

}

控制页面屏幕横竖屏

这两种方法都是在屏幕发生旋转是进行回调的因某些页面需要固定竖屏,但并未找到苹果有公开控制屏幕方向的方法,只能用私有方法来处理啦🤷‍♀️

    if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {

        SELselector  =NSSelectorFromString(@"setOrientation:");

        NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]];

        [invocationsetSelector:selector];

        [invocationsetTarget:[UIDevice currentDevice]];

        UIInterfaceOrientationMask val = direction;

        [invocationsetArgument:&valatIndex:2];

        [invocationinvoke];

    }

写完这些觉得大功告成了吧,然ios13横屏进入可横竖屏的界面不响应方式一、方式二方法,之前系统版本都正常,🤷‍♀️

那也得适配ios13不是只能在改变canDirection及改回canDirection是手动调用APPDelegate的方法啦,到这完成

4、获取WiFi名称需定位权限

由于App是做物联网产品,WiFi名称无处不在呀,然获取到的都是WLAN,只能写个公用方法授权定位啦,有些与硬件传输数据需要不断的获取WiFi名称判断是否处于断连,允许一次的用户o(╥﹏╥)o就无奈了

上一篇下一篇

猜你喜欢

热点阅读