注册 登录
主题 : A首次push界面 B 会卡顿,第二次就不会了,什么原因
级别: 侠客
状态: 连续签到 - [1天]
UID: 622639
精华: 0
发帖: 92
可可豆: 243 CB
威望: 239 点
在线时间: 236(时)
注册时间: 2017-09-01
最后登录: 2019-09-12
0 楼:  发表于: 2019-08-27 09:49    发自: Web Page
来源于 调试问题 分类

A首次push界面 B 会卡顿,第二次就不会了,什么原因   

B 为聊天界面。


viewdidload 调用:



- (void)xx_addSubviews
{
? ? [self.view addSubview:self.chatListView];
? ? [self.view addSubview:self.inputPanel];
? ? [self.view addSubview:self.editView];
? ? WeakSelf(ws);
? ? [self.chatListView mas_makeConstraints:^(MASConstraintMaker *make) {
? ? ? ? if (@available(iOS 11, *)) {
? ? ? ? ? ? make.top.mas_equalTo(ws.view.safeAreaInsets.top);
? ? ? ? } else {
? ? ? ? ? ? make.top.equalTo(ws.view);
? ? ? ? }
? ? ? ? make.left.equalTo(ws.view);
? ? ? ? make.right.equalTo(ws.view);
? ? ? ? make.bottom.mas_equalTo(ws.inputPanel.mas_top);
? ? }];
}


- (void)xx_bindViewModel
{
@weakify(self);
? ? [[[[[olym_Nofity rac_addObserverForName:kMJTIMNewMsgNotifaction object:nil] takeUntil:self.rac_willDeallocSignal] map:^id(NSNotification *value) {
? ? ? ? return value;
? ? }] distinctUntilChanged] subscribeNext:^(NSNotification *notification) {
? ? ? ? @strongify(self);
dispatch_async(dispatch_get_main_queue(), ^{
? ? ? ? ? ? [self.chatListView doRefreshMessageList:notification delay:0.1];
? ? ? ? });

? ? }];
? ?...


? // 这里都是rac的订阅 内容有点多,其中ViewModel的懒加载是有查询数据库的,注释掉依旧有问题


}


关键词: 卡顿
你的衣衫破旧
而歌声却温柔
级别: 新手上路
UID: 510353
精华: 0
发帖: 43
可可豆: 151 CB
威望: 151 点
在线时间: 662(时)
注册时间: 2015-09-30
最后登录: 2019-09-12
1 楼:  发表于: 2019-08-27 10:11    发自: Web Page
这个代码也看不出啥
级别: 侠客
状态: 连续签到 - [1天]
UID: 622639
精华: 0
发帖: 92
可可豆: 243 CB
威望: 239 点
在线时间: 236(时)
注册时间: 2017-09-01
最后登录: 2019-09-12
2 楼:  发表于: 2019-08-27 10:18    发自: Web Page
回 1楼(Mr_ZJ) 的帖子
进入的时候调用的就这些 ,下面懒加载
- (TableEditView *)editView
{
    if (!_editView) {
        CGFloat originY = GJCFSystemNavigationBarHeight + GJCFSystemOriginYDelta + InputPanelBottomMargin;
        _editView = [[TableEditView alloc] initWithFrame:(CGRect){0, GJCFSystemScreenHeight - self.inputPanel.inputBarHeight - originY, GJCFSystemScreenWidth, self.inputPanel.inputBarHeight + 216 + InputPanelBottomMargin} editType:(TableEditType)(TableEditDeleteType | TableEditForwardType)];
        _editView.hidden = YES;
        WeakSelf(weakSelf)
            _editView.editViewButtonClick = ^(TableEditType type) {
            if (type == TableEditDeleteType) {
                [AlertViewManager actionSheettWithTitle:nil
                                                message:nil
                                           actionNumber:2
                                           actionTitles:@[ @"删除", @"取消" ]
                                          actionHandler:^(UIAlertAction *action, NSUInteger index) {
                                              if (index == 0) {
                                                  [weakSelf deleteSelectedMessages];
                                              }
                                          }];
            } else if (type == TableEditForwardType) {
                [weakSelf forwardSelectedMessages];
            }
        };
    }
    return _editView;
}

- (GJGCChatInputPanel *)inputPanel
{

    if (!_inputPanel) {

        _inputPanel = [[GJGCChatInputPanel alloc] initWithPanelDelegate:self];
        NSString *formateNoti = [GJGCChatInputConst panelNoti:GJGCChatInputTextViewContentChangeNoti formateWithIdentifier:_inputPanel.panelIndentifier];
        [GJCFNotificationCenter addObserver:self selector:@selector(updateInputTextContent:) name:formateNoti object:nil];

        CGFloat originY = GJCFSystemNavigationBarHeight + GJCFSystemOriginYDelta + InputPanelBottomMargin;
        self.inputPanel.frame = (CGRect){0, GJCFSystemScreenHeight - self.inputPanel.inputBarHeight - originY, GJCFSystemScreenWidth, self.inputPanel.inputBarHeight + 216 + InputPanelBottomMargin};

        if (self.currentChatUser.roomFlag || [self.currentChatUser.userId isEqualToString:olym_UserCenter.userId]) {
            if (![[TargetConfig shareInstance] supportGroupSIP]) {

                //群聊中电话按钮隐藏
                for (GJGCChatInputExpandMenuPanelItem *item in _inputPanel.menuPanel.contentScrollView.subviews) {

                    if ([item.titleLabel.text isEqualToString:@"电话"]) {

                        [item removeFromSuperview];
                    }
                }
            }
            if(!self.currentChatUser.roomFlag){
                //文件传输助手中电话按钮隐藏
                for (GJGCChatInputExpandMenuPanelItem *item in _inputPanel.menuPanel.contentScrollView.subviews) {

                    if ([item.titleLabel.text isEqualToString:@"电话"]) {

                        [item removeFromSuperview];
                    }
                }
            }
        }

        _inputPanel.delegate = self;

        WeakSelf(weakSelf);
#if ThirdlyVersion
        if(self.currentChatUser.draftContent)
        {
            NSArray *draftArray = [self.currentChatUser.draftContent componentsSeparatedByString:@"$:!aipn$"];
            NSString *draftContent = [draftArray firstObject];
            _inputPanel.inputBarTextViewContent = draftContent;
            //FIXME: 将草稿中@人的userId重新赋值
            if (draftArray.count > 1)
            {
                [self.chatViewModel.reminderArray addObjectsFromArray:[JsonUtils jsonStringToArray:[draftArray lastObject]]];
            }
        }
#endif

        [_inputPanel configInputPanelKeyboardFrameChange:^(GJGCChatInputPanel *panel, CGRect keyboardBeginFrame, CGRect keyboardEndFrame, NSTimeInterval duration, BOOL isPanelReserve) {
            /* 不要影响其他不带输入面板的系统视图对话 */
            if (panel.hidden) {
                return;
            }
            CGFloat originY1 = originY - InputPanelBottomMargin;
            [UIView animateWithDuration:duration
                             animations:^{
                                 weakSelf.chatListView.gjcf_height = GJCFSystemScreenHeight - weakSelf.inputPanel.inputBarHeight - originY1 - keyboardEndFrame.size.height;

                                 if (keyboardEndFrame.origin.y == GJCFSystemScreenHeight) {

                                     if (isPanelReserve) {

                                         weakSelf.inputPanel.gjcf_top = GJCFSystemScreenHeight - weakSelf.inputPanel.inputBarHeight - originY;

                                         weakSelf.chatListView.gjcf_height = GJCFSystemScreenHeight - weakSelf.inputPanel.inputBarHeight - originY;

                                     } else {

                                         weakSelf.inputPanel.gjcf_top = GJCFSystemScreenHeight - 216 - weakSelf.inputPanel.inputBarHeight - originY;

                                         weakSelf.chatListView.gjcf_height = GJCFSystemScreenHeight - weakSelf.inputPanel.inputBarHeight - originY - 216;
                                     }

                                 } else {

                                     weakSelf.inputPanel.gjcf_top = weakSelf.chatListView.gjcf_bottom;
                                     if (IS_IPHONE_X) {
                                         if (weakSelf.inputPanel.inputBarHeight > 50) {
                                             weakSelf.inputPanel.gjcf_top = weakSelf.chatListView.gjcf_bottom + InputPanelBottomMargin;
                                         }
                                     }
                                 }
                                 [weakSelf.chatListView layoutIfNeeded];
                             }];

            [weakSelf.chatListView.tableView scrollRectToVisible:CGRectMake(0, weakSelf.chatListView.tableView.contentSize.height - weakSelf.chatListView.bounds.size.height, weakSelf.chatListView.gjcf_width, weakSelf.chatListView.gjcf_height) animated:NO];
        }];

        [_inputPanel configInputPanelRecordStateChange:^(GJGCChatInputPanel *panel, BOOL isRecording) {
            if (isRecording) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    weakSelf.chatListView.userInteractionEnabled = NO;
                });
            } else {
                dispatch_async(dispatch_get_main_queue(), ^{
                    weakSelf.chatListView.userInteractionEnabled = YES;
                });
            }
        }];

        [_inputPanel configInputPanelInputTextViewHeightChangedBlock:^(GJGCChatInputPanel *panel, CGFloat changeDelta) {
            panel.gjcf_top = panel.gjcf_top - changeDelta;

            panel.gjcf_height = panel.gjcf_height + changeDelta;

            [UIView animateWithDuration:0.2
                             animations:^{
                                 weakSelf.chatListView.gjcf_height = weakSelf.chatListView.gjcf_height - changeDelta;
                                 [weakSelf.chatListView layoutIfNeeded];

                                 [weakSelf.chatListView.tableView scrollRectToVisible:CGRectMake(0, weakSelf.chatListView.tableView.contentSize.height - weakSelf.chatListView.bounds.size.height, weakSelf.chatListView.gjcf_width, weakSelf.chatListView.gjcf_height) animated:NO];
                             }];
        }];

        /* 动作变化 */
        [_inputPanel setActionChangeBlock:^(GJGCChatInputBar *inputBar, GJGCChatInputBarActionType toActionType) {
            [weakSelf inputBar:inputBar changeToAction:toActionType];
        }];
    }
    return _inputPanel;
}

- (ChatViewModel *)chatViewModel
{
    if (!_chatViewModel) {
        if (self.searchMessaegObject) {
            _chatViewModel = [[ChatViewModel alloc] initWithUser:self.currentChatUser searchMessage:self.searchMessaegObject];
        } else {
            _chatViewModel = [[ChatViewModel alloc] initWithUser:self.currentChatUser];
        }
    }
    return _chatViewModel;
}

- (ChatListView *)chatListView
{
    if (!_chatListView) {
        _chatListView = [[ChatListView alloc] initWithViewModel:self.chatViewModel];
        _chatListView.currentChatUser = self.currentChatUser;
    }
    return _chatListView;
}
你的衣衫破旧
而歌声却温柔
级别: 新手上路
UID: 455538
精华: 0
发帖: 2
可可豆: 2 CB
威望: 2 点
在线时间: 188(时)
注册时间: 2015-03-29
最后登录: 2019-09-12
3 楼:  发表于: 2019-08-27 10:26    发自: Web Page
看看是不是透明背景没设置颜色
级别: 侠客
状态: 连续签到 - [1天]
UID: 578736
精华: 0
发帖: 81
可可豆: 183 CB
威望: 183 点
在线时间: 516(时)
注册时间: 2016-08-19
最后登录: 2019-09-12
4 楼:  发表于: 2019-08-27 10:27    发自: Web Page
或许你push的时候没有用动画 设置成有动画的试试
级别: 侠客
状态: 连续签到 - [1天]
UID: 622639
精华: 0
发帖: 92
可可豆: 243 CB
威望: 239 点
在线时间: 236(时)
注册时间: 2017-09-01
最后登录: 2019-09-12
5 楼:  发表于: 2019-08-27 10:28    发自: Web Page
回 3楼(王晨晓) 的帖子
rootViewControler 就已经设置了
你的衣衫破旧
而歌声却温柔
级别: 侠客
状态: 连续签到 - [1天]
UID: 622639
精华: 0
发帖: 92
可可豆: 243 CB
威望: 239 点
在线时间: 236(时)
注册时间: 2017-09-01
最后登录: 2019-09-12
6 楼:  发表于: 2019-08-27 10:29    发自: Web Page
回 4楼(FF小猿) 的帖子
有动画 设置的YES
你的衣衫破旧
而歌声却温柔
级别: 骑士
UID: 498282
精华: 0
发帖: 232
可可豆: 250 CB
威望: 250 点
在线时间: 509(时)
注册时间: 2015-08-17
最后登录: 2019-09-11
7 楼:  发表于: 2019-08-27 12:00    发自: Web Page
uitextView  uitextField 搞的鬼 可以注释掉试试看
级别: 侠客
状态: 连续签到 - [1天]
UID: 622639
精华: 0
发帖: 92
可可豆: 243 CB
威望: 239 点
在线时间: 236(时)
注册时间: 2017-09-01
最后登录: 2019-09-12
8 楼:  发表于: 2019-08-27 15:38    发自: Web Page
回 7楼(Cat_) 的帖子
你说的 我在网上有找到过 试了 没用哎
你的衣衫破旧
而歌声却温柔
级别: 新手上路
状态: 连续签到 - [1天]
UID: 537275
精华: 0
发帖: 3
可可豆: 6 CB
威望: 4 点
在线时间: 15(时)
注册时间: 2016-01-08
最后登录: 2019-09-02
9 楼:  发表于: 2019-08-27 15:56    发自: Web Page
看一下,是不是第一次有什么全局的值没有初始化,进界面之后就初始化了,再次进入就不会卡,要不然的话,看一下背景色

CocoaChina社区转载内容已尽可能注明出处,如未能核实来源或转发内容图片有权利瑕疵的,请及时联系社区进行修改或删除【联系方式QQ : 3442093904 邮箱:support@cocoachina.com】文章内容为作者独立观点,不代表CocoaChina社区立场。版权归原作者所有,如申请授权请联系作者,因文章侵权CocoaChina社区不承担任何法律及连带责任。

描述
快速回复

关注本帖(如果有新回复会站内信通知您)

发帖、回帖都会得到可观的积分奖励。查看论坛积分规则

按"Ctrl+Enter"直接提交
顶部