美文网首页
iOS关于启动页复用的做法

iOS关于启动页复用的做法

作者: 王看山 | 来源:发表于2022-04-14 19:53 被阅读0次
1.前段时间给公司app做安全性检测的部门提出了关于越狱手机启动页篡改的漏洞,问题很严峻,领导很重视,搞了几天,没头绪。各种越狱手机检测都没生效,逼得最终使用大招,不用launchImage asset来做启动页面了,直接用storyboard来搞起,解压app的ipa包后欢迎页图片被隐藏了,让别人无从篡改启动页,安全漏洞问题就过了。
2.用storyboard还可以对欢迎页在请求接口时,直接复用,避免的重写冗余代码和图片,请求第一个接口,判断版本升级和设备信息时复用启动页展示,请求成功后移除即可。

启动页的storyboard创建和图片设置部分就不提了,这里主要说说我在请求app第一个接口时怎么复用启动页吧,思路是这样的:
取到storyboard中的启动页view-->在请求app第一个接口时,添加到顶部Window中-->在请求结果返回后移除即可。

    //为了去除启动页到欢迎页的页面差异,欢迎页请求接口时,直接复用启动页storyboard添加到keyWindow
    UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
    self.launchView = [[UIStoryboard storyboardWithName:@"WelcomeSence" bundle:[NSBundle mainBundle]] instantiateInitialViewController].view;
    UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    [self.launchView addSubview:activityView];
    activityView.center = self.launchView.center;
    [activityView startAnimating];
    self.activityIndicator.center = self.launchView.center;
    [keyWindow addSubview:self.launchView];

相关文章

网友评论

      本文标题:iOS关于启动页复用的做法

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