页面管理

来源:互联网 发布:云计算基础设施建设 编辑:程序博客网 时间:2024/05/17 03:40

页面管理决定一个app的质量。没有中央页面管理组件,轻者造成实现页面处理麻烦,每个应用都要实现自己自己的页面管理,不利于实现页面状态机;重者容易产生页面页面循环引用,不能及时释放,通知事件没有正常移除造成崩溃。
正确的中央页面管理组件,要达到像这样的效果,调用一个url地址就能实现页面跳转和实现页面跳转时的动画。怎么实现实时移除上个页面呢?就是进入另一个新页面,发送通知,上一个页面接到通知从UINavigationController移除该页面。在页面销毁函数中,增加像下面的代码一样移除通知:

- (void)dealloc{    _mapView.delegate = nil;    [[NSNotificationCenter defaultCenter] removeObserver:self];    NSLog(@"dealloc");}

在arc机制下,一旦你使用了定时器,就是你离开页面是把定时器指针置为空,你的页面也不能实时销毁。完美解决方案是使用NSTimer+YYAdd这个库来实现定时器的调用。示例代码:

        if (!(_timer.isValid)) {            @weakify(self);            self.timer = [NSTimer scheduledTimerWithTimeInterval:1.f block:^(NSTimer * _Nonnull timer) {                @strongify(self);                [self readmis];            } repeats:YES];            [self.timer setFireDate:[NSDate distantPast]];        }        else        {            [_timer setFireDate:[NSDate distantPast]];        }
//读秒-(void)readmis{    if(self.sendVerificationCodeWaitTime > 0)    {        self.sendVerificationCodeWaitTime--;    }    if (self.sendVerificationCodeWaitTime == 0)    {        self.repeatBtn.enabled=YES;        [self.repeatBtn setTitleColor:[UIColor colorWithHexString:@"0X0F9B70"] forState:UIControlStateNormal];        [self.repeatBtn setTitle:@"请重新发送" forState:UIControlStateNormal];        self.repeatBtn.userInteractionEnabled = YES;        [self.timer setFireDate:[NSDate distantFuture]];    }    else    {        [self.repeatBtn setTitleColor:[UIColor colorWithHexString:@"0X8A9399"] forState:UIControlStateNormal];        NSString*timeStr=[NSString stringWithFormat:@"%lu秒后重试",(unsigned long)self.sendVerificationCodeWaitTime];        self.repeatBtn.enabled=NO;        //    这样设置不会闪烁        self.repeatBtn.titleLabel.text= timeStr;        [self.repeatBtn setTitle:timeStr forState:UIControlStateDisabled];        self.repeatBtn.userInteractionEnabled = NO;    }    self.repeatBtn.titleLabel.textAlignment = NSTextAlignmentRight;    self.repeatBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;}

我们使用是自己做的页面跳转组件,页面跳转的示例代码如下:

            [YXRouter openURL:@"gb://test" completion:^(id result) {                [[NSNotificationCenter defaultCenter] postNotificationName:orderPrepareEvalute object:nil];            }];

再具体的不便于近一步说了,那涉及公司技术秘密了。
做程序猿的就要有day day up的觉悟,不进则退。
现在比较时髦的技术是mmvvm与ReactiveCocoa,布局第三方库(如:SDAutoLayout。苹果自带的布局库操作太不方便了,特别是storyboard想动态修改它太不方便了,并且会严重增大app),混合开发(React Native等),指定范围或特定人群试用新功能,埋点,热修复,页面下发管理中心,无线网关(应用启动建立https的ssl隧道,需要证书认证,并保存会话信息到内存中。当认证成功后,ssl隧道断开(,再发送https请求都携带会话信息,当网关收到这样的https请求并且核对会话信息正确,不再进行证书认证直接建立通道),聚合层(多个不相关接口合并成一个接口),懒加载,无线配置中心(服务器下发配置中心数据更新消息,客户端解析消息,根据解析的消息结果来决定是否向服务器下载数据),模块化(私有库),git工作流,jenkins自动打包上传,混合编程(objec c和c ++混合编程,如:通用长连接库用c++写,安卓和苹果客户端都能调用),swift。