dequeueReusableCellWithIdentifier vs dequeueReusableCellWithIdentifier : forIndexPath

本文详细解析了UITableView在Swift中使用过程中遇到的cell加载问题,包括如何正确注册cell类或nib文件,以及未注册时可能引发的应用崩溃等问题。


non-forIndexPath: version returns nil in that case.


forIndexPath: version asserts (crashes) if you didn't register a class or nib for the identifier.


forIndexPath:  must register a class or nib file using the registerNib:forCellReuseIdentifier: or registerClass:forCellReuseIdentifier: method before calling this method.

也就是cell是存在的。当无cell 时是不可以用的


分析一下下面出现该问题的页面Identified traffic页,如果数据都为0,应该关注哪些代码? bug描述 Bug 1179443 - 【论坛反馈】【Client详情页】OC200 V6 Client statistics-traffic点击进入Identified traffic页无数据 (edit) 基本信息► 审核区域▼ Status: ASSIGNED (edit) Importance: major (edit) Bug的类别: Function (edit) 出现频率: 必然 (edit) 能否恢复: --- (edit) 测试拓扑: (edit) 陪测设备: 1、OC200 6.0.0.34 (edit) 重现步骤: 1、进入V6版本OC200 Client详情页 statistics-traffic中 (edit) 测试结果: 1、Traffic 未进入时有数据,点击进入Identified traffic无数据 (edit) 期望结果: 1、正确显示数据 (edit) 问题产品: 1、Omada_5.0.132(2) (edit) 对比测试: 1、安卓端出现相同问题 (edit) 问题分析: 1、望分析 (edit) 影响评估: 1、影响用户体验 (edit) // // SDNStaticsClientDetailViewController.m // Omada // // Created by aobinfeng on 2024/4/23. // Copyright © 2024 TP-Link. All rights reserved. // #import "SDNStaticsClientDetailViewController.h" #import "SDNStaticClientDetailCell.h" #import "SDNStaticsTrafficPercentView.h" #import "DMSDNStaticsClientAppTraffic.h" #import "SDNClientDetailFlexibleBar.h" #import "SDNAppClientDetailTrafficViewModel.h" #import "TPClientsAvatarManager.h" #import "SDNStaticsTrafficPercentView.h" #import "SDNDashboardSelectTimeView.h" #import "SDNLogSelectDateRangeView.h" #import "TPSDNTimeZoneHelp.h" #import "SDNClientListRefreshFooter.h" #import "SDNDashboardCategoryOverView.h" #import "SDNPermissionTool.h" #import "SDNClientsViewController.h" #import "VMSDNConnectedClient.h" #import "TPConvTools.h" #import "OMDClientFlexibleHeader.h" #define Day_Million_Seconds (60 * 60 * 24 * 1000) @interface SDNStaticsClientDetailViewController () <UITableViewDelegate, UITableViewDataSource> @property (nonatomic, strong) UITableView *tableView; @property (nonatomic, assign) int currentPage; @property (nonatomic, assign) int totalRow; @property (nonatomic, strong) SDNStaticsTrafficPercentView *trafficPercentView; @property (nonatomic, strong) UIView *tableViewHeaderView; @property (nonatomic, strong) DMSDNStaticsClientAppTraffic *clientAppsTraffic; //@property (nonatomic, strong) SDNClientDetailFlexibleBar *flexibleBar; @property (nonatomic, strong) TPBPullDownHeader *pullDownHeader; @property (nonatomic, strong) SDNAppClientDetailTrafficViewModel *vmFlexibleBar; @property (nonatomic, strong) SDNDashboardSelectTimeView *selectedTimeView; @property (nonatomic, copy) NSString *selectTimeDetailStr; @property (nonatomic, strong) UILabel *selectedTimeLabel; @property (nonatomic, strong) UIRefreshControl *refreshControl; @property (nonatomic, strong) TPAbstractHandle *clientAppTrafficRequest; @property (nonatomic, strong) TPAbstractHandle *categoriesRequest; @property (nonatomic, strong) TPAbstractHandle *requestConnectedClientListHandle; @property (nonatomic, strong) NSMutableDictionary *searchFieldDic; @property (nonatomic, strong) NSMutableArray *dmClientArray; @property (nonatomic, strong) VMSDNConnectedClient *vmConnectedClient; @end @implementation SDNStaticsClientDetailViewController - (instancetype)init { self = [super init]; if (self) { self.categories = [DMSDNDashboardCategory new]; self.dateType = SDNLogSelectDateTypeLast24Hours; self.mac = @""; self.searchFieldDic = [NSMutableDictionary new]; self.searchFieldDic[@"searchField"] = @"clientName,clientMac,ip"; self.currentVCType = StaticsClientDetailVCTypeDefault; } return self; } - (void)viewDidLoad { [super viewDidLoad]; [self buildNav]; [self buildView]; if (self.isNeedFlexibleBar) { TPWeakSelf [[self requestConnectedClientListWithMac:self.mac] addCompletionOnMainThread:^(TPHandleResult * _Nonnull result) { TPStrongSelf if (result.success) { if (_self.dmClientArray.count > 0) { _self.vmConnectedClient = [[VMSDNConnectedClient alloc] initWithDMSDNClient: _self.dmClientArray[0]]; [_self initFlexibleBar]; } else { self.vmFlexibleBar = [[SDNAppClientDetailTrafficViewModel alloc] initWithDetailTraffic:self.appClientDetailTraffic]; [self initFlexibleBarV2]; } } }]; } self.currentPage = 1; self.totalRow = 0; self.clientAppsTraffic = [DMSDNStaticsClientAppTraffic new]; [self setupRefreshFooter]; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; if (self.isNeedFlexibleBar) { [self handleHeaderRefresh]; } else { TPWeakSelf [[self requestCategories] addCompletionOnMainThread:^(TPHandleResult * _Nonnull result) { TPStrongSelf [_self handleHeaderRefresh]; }]; } } //MARK: --buildView - (void)initFlexibleBarV2 { DMSDNSiteClient *client = [DMSDNSiteClient new]; client.name = self.name; client.clientType = self.type; client.isWireless = self.vmFlexibleBar.isWireless; client.isOnline = NO; VMSDNConnectedClient *vmClient = [[VMSDNConnectedClient alloc] initWithDMSDNClient:client]; OMDClientFlexibleHeader *headerView = [OMDClientFlexibleHeader new]; [headerView updateWithDM:vmClient]; TPBPullDownHeader *header = [TPBPullDownHeader headerWithCustomLargeTitle:headerView]; self.tpbPullDownHeader = header; } -(void)initFlexibleBar { OMDClientFlexibleHeader *headerView = [OMDClientFlexibleHeader new]; [headerView updateWithDM:self.vmConnectedClient]; TPBPullDownHeader *header = [TPBPullDownHeader headerWithCustomLargeTitle:headerView]; header.title = self.vmConnectedClient.name; self.tpbPullDownHeader = header; } - (void)buildNav { if (self.isNeedFlexibleBar) { self.isNavigationBarTransparent = YES; } else { self.navigationItem.title = gMeshQuickSetup.sdnStaticsIdentifitedTraffic; } UIBarButtonItem *leftBarButtonItem = [self createBarButtonItemItemWithStyle:TPViewControllerBarButtonItemStyleBackInWhite andTarget:self andAction:@selector(clickBack)]; leftBarButtonItem.accessibilityLabel = gAccessibility.back; self.navigationItem.leftBarButtonItem = leftBarButtonItem; if (self.currentVCType == StaticsClientDetailVCTypeV6) { self.navigationItem.rightBarButtonItem = [self tpbCreateRightBarButtonItemWithImage:[UIImage imageNamed:@"SDNDashbordDateRange"] andTarget:self andAction:@selector(clickSelectDateRange)]; } else { self.navigationItem.rightBarButtonItem = nil; } } - (void)buildView { [self.view addSubview:self.tableView]; TPWeakSelf; [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { TPStrongSelf; make.top.equalTo( _self.mas_tpSafeAreaLayoutGuide); make.bottom.equalTo( _self.view); make.leading.equalTo( _self.mas_tpSafeAreaLayoutGuide); make.trailing.equalTo( _self.mas_tpSafeAreaLayoutGuide); }]; } - (void)buildHeaderView { self.trafficPercentView = [[SDNStaticsTrafficPercentView alloc] initWithTraffic:self.clientAppsTraffic]; [self.trafficPercentView tpbConfigCardStyle]; self.tableViewHeaderView = [UIView new]; self.tableViewHeaderView.frame = CGRectMake(0, 0, kScreen_Width, 200); [self.tableViewHeaderView addSubview:self.selectedTimeView]; [self.tableViewHeaderView addSubview:self.trafficPercentView]; [self.selectedTimeView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.tableViewHeaderView).offset(20); make.leading.equalTo(self.tableViewHeaderView).offset(TPBDesign.list.sectionContentLeading); }]; [self.trafficPercentView mas_makeConstraints:^(MASConstraintMaker *make) { if (self.selectedTimeView.hidden) { make.top.equalTo(self.tableViewHeaderView).offset(20); } else { make.top.equalTo(self.selectedTimeView.mas_bottom).offset(16); } // make.leading.trailing.equalTo(self.selectedTimeView); make.leading.equalTo(self.tableViewHeaderView).offset(TPBDesign.list.contentLeading); make.trailing.equalTo(self.tableViewHeaderView).offset(-TPBDesign.list.contentLeading); make.bottom.equalTo(self.tableViewHeaderView).offset(-20); }]; CGFloat height = [self.tableViewHeaderView systemLayoutSizeFittingSize:CGSizeMake(kScreen_Width, CGFLOAT_MIN) withHorizontalFittingPriority:UILayoutPriorityRequired verticalFittingPriority:UILayoutPriorityFittingSizeLevel].height; self.tableViewHeaderView.frame = CGRectMake(0, 0, kScreen_Width, height); self.tableView.tableHeaderView = self.tableViewHeaderView; } - (void)setupRefreshFooter { TPWeakSelf SDNClientListRefreshFooter *footer = [SDNClientListRefreshFooter footerWithRefreshingBlock:^{ TPStrongSelf [_self loadMorePageData]; }]; footer.stateLabel.numberOfLines = 0; footer.stateLabel.userInteractionEnabled = NO; [footer setTitle:gSDNMore.sdnNoMoreData forState:MJRefreshStateNoMoreData]; self.tableView.mj_footer = footer; } //MARK: --UI刷新 - (void)reloadView { [self updateSeletedTimeAndString]; [self.trafficPercentView updateWithTraffic:self.clientAppsTraffic]; [self.selectedTimeView updateBtnTitle:self.selectTimeDetailStr]; [self.tableView reloadData]; } - (void)updateSeletedTimeAndString { if(self.dateType == SDNLogSelectDateTypeToday) { [self updateTodayTime]; } else if (self.dateType == SDNLogSelectDateTypeYestoday) { [self updateYestodayTime]; } else { if (self.dateType == SDNLogSelectDateTypeLast24Hours) { self.canlendarEndTime = [TPSDNControllerClient currentInstance].maintenanceComponent.controllerInfo.systemTime; self.canlendarStartTime = self.canlendarEndTime - (long)Day_Million_Seconds; } else if (self.dateType == SDNLogSelectDateTypeLast7Days) { self.canlendarEndTime = [TPSDNControllerClient currentInstance].maintenanceComponent.controllerInfo.systemTime; self.canlendarStartTime = self.canlendarEndTime - (long)7 * Day_Million_Seconds; } else if (self.dateType == SDNLogSelectDateTypeLast14Days) { self.canlendarEndTime = [TPSDNControllerClient currentInstance].maintenanceComponent.controllerInfo.systemTime; self.canlendarStartTime = self.canlendarEndTime - (long)14 * Day_Million_Seconds; } else if (self.dateType == SDNLogSelectDateTypeLast30Days) { self.canlendarEndTime = [TPSDNControllerClient currentInstance].maintenanceComponent.controllerInfo.systemTime; self.canlendarStartTime = self.canlendarEndTime - (long)30 * Day_Million_Seconds; } NSString *startTimeStr = [self dateStringFromTimeInterval:self.canlendarStartTime]; NSString *endTimeStr = [self dateStringFromTimeInterval:self.canlendarEndTime]; if([startTimeStr isEqualToString:endTimeStr]) { self.selectTimeDetailStr = startTimeStr; self.selectedTimeLabel.text = startTimeStr; } else { self.selectTimeDetailStr = [NSString stringWithFormat:@"%@ - %@", startTimeStr, endTimeStr]; self.selectedTimeLabel.text = [NSString stringWithFormat:@"%@ - %@", startTimeStr, endTimeStr]; } } } - (void)updateTodayTime { self.canlendarEndTime = [TPSDNControllerClient currentInstance].maintenanceComponent.controllerInfo.systemTime; NSTimeInterval displayInterval = [self dstTimeWithTimeInterval:self.canlendarEndTime]; NSCalendar *gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian]; NSDate *displaDate = [[NSDate date] initWithTimeIntervalSince1970:displayInterval / 1000]; NSTimeZone *timeZone = [TPSDNTimeZoneHelp getCurrentTimeZone]; NSDateComponents *displayDateCpt = [gregorianCalendar componentsInTimeZone:timeZone fromDate:displaDate]; [self updateComponents:displayDateCpt andIsStart:YES]; NSDateFormatter *dateFormatter = [self currentTimeZoneDateFormatter]; NSDate *disPlayBeginDate = [gregorianCalendar dateFromComponents:displayDateCpt]; NSString *dateString = [dateFormatter stringFromDate:disPlayBeginDate]; NSTimeInterval beginTimeInterval = [disPlayBeginDate timeIntervalSince1970]; NSTimeInterval beginOriginInterval = [self originTimeWithTimeInterval:beginTimeInterval * 1000]; self.canlendarStartTime = beginOriginInterval; self.selectedTimeLabel.text = dateString; self.selectTimeDetailStr = dateString; } - (void)updateYestodayTime { NSTimeInterval endTime = [TPSDNControllerClient currentInstance].maintenanceComponent.controllerInfo.systemTime - Day_Million_Seconds; NSTimeInterval displayInterval = [self dstTimeWithTimeInterval:endTime]; NSCalendar *gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian]; NSDate *displaDate = [[NSDate date] initWithTimeIntervalSince1970:displayInterval / 1000]; NSTimeZone *timeZone = [TPSDNTimeZoneHelp getCurrentTimeZone]; NSDateComponents *displayDateCpt = [gregorianCalendar componentsInTimeZone:timeZone fromDate:displaDate]; [self updateComponents:displayDateCpt andIsStart:NO]; NSDateFormatter *dateFormatter = [self currentTimeZoneDateFormatter]; NSDate *displayDate = [gregorianCalendar dateFromComponents:displayDateCpt]; NSString *dateString = [dateFormatter stringFromDate:displayDate]; NSTimeInterval dstDisplayTimeInterval = [displayDate timeIntervalSince1970]; NSTimeInterval originTimeInterval = [self originTimeWithTimeInterval:dstDisplayTimeInterval * 1000]; self.canlendarEndTime = originTimeInterval; self.canlendarStartTime = self.canlendarEndTime - Day_Million_Seconds + 1 * 1000; self.selectedTimeLabel.text = dateString; self.selectTimeDetailStr = dateString; } - (NSString *)dateStringFromTimeInterval:(NSTimeInterval)timeInterval { NSCalendar *gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian]; NSTimeInterval displayTimeInterval = [self dstTimeWithTimeInterval:timeInterval]; NSDate *displaDate = [[NSDate date] initWithTimeIntervalSince1970:displayTimeInterval / 1000]; NSTimeZone *timeZone = [TPSDNTimeZoneHelp getCurrentTimeZone]; NSDateComponents *displayDateCpt = [gregorianCalendar componentsInTimeZone:timeZone fromDate:displaDate]; NSDateFormatter *dateFormatter = [self currentTimeZoneDateFormatter]; NSDate *displayDate = [gregorianCalendar dateFromComponents:displayDateCpt]; NSString *dateString = [dateFormatter stringFromDate:displayDate]; return dateString; } - (NSTimeInterval)dstTimeWithTimeInterval:(NSTimeInterval)timeInterval { DMSDNSiteDSTInfo *dstInfo = [[DMSDNSiteDSTInfo alloc] init]; dstInfo = [TPSDNControllerClient currentInstance].siteConfigComponent.currentSiteSettings.siteBasicSetting.dstInfo; BOOL DSTEnable = dstInfo.enable; if(DSTEnable) { return [dstInfo dstTimeWithOriginalTime:timeInterval andDSTEnable:DSTEnable]; } else { return timeInterval; } } - (void)updateComponents:(NSDateComponents *)components andIsStart:(BOOL)isStart { if(isStart) { components.hour = 0; components.minute = 0; components.second = 0; } else { components.hour = 23; components.minute = 59; components.second = 59; } } - (NSDateFormatter *)currentTimeZoneDateFormatter { NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; formatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]; formatter.calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian]; formatter.timeZone = [TPSDNTimeZoneHelp getCurrentTimeZone]; formatter.dateFormat = @"yyyy/MM/dd"; return formatter; } - (NSTimeInterval)originTimeWithTimeInterval:(NSTimeInterval)timeInterval { DMSDNSiteDSTInfo *dstInfo = [TPSDNControllerClient currentInstance].siteConfigComponent.currentSiteSettings.siteBasicSetting.dstInfo; BOOL DSTEnable = dstInfo.enable; if(DSTEnable) { return [dstInfo originTimeWithDstTime:timeInterval andDSTEnable:DSTEnable]; } else { return timeInterval; } } //MARK: --点击事件 - (void)clickBack { [self.navigationController popViewControllerAnimated:YES]; } - (void)clickSelectDateRange { SDNLogSelectDateType dateType = self.dateType; NSInteger selectIndex = -1; switch (dateType) { case SDNLogSelectDateTypeToday: selectIndex = 0; break; case SDNLogSelectDateTypeYestoday: selectIndex = 1; break; case SDNLogSelectDateTypeLast24Hours: selectIndex = 2; break; case SDNLogSelectDateTypeLast7Days: selectIndex = 3; break; case SDNLogSelectDateTypeLast14Days: selectIndex = 4; break; case SDNLogSelectDateTypeLast30Days: selectIndex = 5; break; case SDNLogSelectDateTypeCustom: selectIndex = 6; break; default: break; } NSMutableArray *itemsArray = [[NSMutableArray alloc] init]; SDNLogSelectTimeItemView *todayItem = [[SDNLogSelectTimeItemView alloc] initWithDateType:SDNLogSelectDateTypeToday isSelect:(selectIndex == 0)]; [itemsArray addObject:todayItem]; SDNLogSelectTimeItemView *yestodayItem = [[SDNLogSelectTimeItemView alloc] initWithDateType:SDNLogSelectDateTypeYestoday isSelect:(selectIndex == 1)]; [itemsArray addObject:yestodayItem]; SDNLogSelectTimeItemView *last24HoursItem = [[SDNLogSelectTimeItemView alloc] initWithDateType:SDNLogSelectDateTypeLast24Hours isSelect:(selectIndex == 2)]; [itemsArray addObject:last24HoursItem]; SDNLogSelectTimeItemView *last7DaysItem = [[SDNLogSelectTimeItemView alloc] initWithDateType:SDNLogSelectDateTypeLast7Days isSelect:(selectIndex == 3)]; [itemsArray addObject:last7DaysItem]; //v6版本client详情页日期筛选屏蔽14days选项 if (![self isControllerV6]) { SDNLogSelectTimeItemView *last14DaysItem = [[SDNLogSelectTimeItemView alloc] initWithDateType:SDNLogSelectDateTypeLast14Days isSelect:(selectIndex == 4)]; [itemsArray addObject:last14DaysItem]; } SDNLogSelectTimeItemView *last30DaysItem = [[SDNLogSelectTimeItemView alloc] initWithDateType:SDNLogSelectDateTypeLast30Days isSelect:(selectIndex == 5)]; [itemsArray addObject:last30DaysItem]; SDNLogSelectTimeItemView *customItem = [[SDNLogSelectTimeItemView alloc] initWithDateType:SDNLogSelectDateTypeCustom isSelect:(selectIndex == 6)]; [itemsArray addObject:customItem]; DMSDNUserLevel curUserLevel = DMSDNUserLevelUnknown; SDNLogSelectDateRangeView *selectView = [[SDNLogSelectDateRangeView alloc] init]; [selectView updateWithTimeItemArray:itemsArray andTitle:gMeshQuickSetup.sdnDateRangeText andStartTime:self.canlendarStartTime andEndTime:self.canlendarEndTime andUserLevel:curUserLevel andDateType:self.dateType andFromStatistics:NO]; TPWeakSelf; selectView.didTapConfirm = ^(int64_t startTime, int64_t endTime, SDNLogSelectDateType dateType) { TPStrongSelf; _self.dateType = dateType; if(dateType == SDNLogSelectDateTypeCustom) { _self.canlendarStartTime = startTime; _self.canlendarEndTime = endTime; } [self updateSeletedTimeAndString]; if (!self.isNeedFlexibleBar) { [[self requestCategories] addCompletionOnMainThread:^(TPHandleResult * _Nonnull result) { TPStrongSelf if (result.success) { [_self handleHeaderRefresh]; } }]; } else { [self handleHeaderRefresh]; } [self.selectedTimeView updateBtnTitle:self.selectTimeDetailStr]; }; [selectView showAnimate]; } //MARK: --UITableView delegate - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.clientAppsTraffic.clientAppTrafficList.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { SDNStaticClientDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:kSDNStaticClientDetailCellIdentifier forIndexPath:indexPath]; [cell updateWithClientApplicationTraffic:self.clientAppsTraffic.clientAppTrafficList[indexPath.row]]; [cell updateCycleViewColor:[SDNDashboardCategoryOverView colorArray][indexPath.row % [SDNDashboardCategoryOverView colorArray].count]]; [cell updateHiddenArrow:YES]; // [cell updateSeparatorWithIndexPath:indexPath andTableView:tableView]; BOOL isLast = self.clientAppsTraffic.clientAppTrafficList.count == indexPath.row + 1; [cell updateBottomSeparatorShow:!isLast]; return cell; } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *view = [UIView new]; if(self.clientAppsTraffic.clientAppTrafficList.count == 0){ return view; } if (section == 0) { UILabel *title = [UILabel new]; title.text = gMeshQuickSetup.sdnTotalTraffic; title.tpbDynamicFont = [UIFont tpbListSubtitle]; title.textColor = [UIColor tpbTextThirdContent]; long totalTraffic = 0; for (DMClientAppTraffic *traffic in self.clientAppsTraffic.clientAppTrafficList) { totalTraffic += traffic.up; totalTraffic += traffic.down; } UILabel *traffic = [UILabel new]; traffic.text = [TPConvTools convBytesToString:totalTraffic]; traffic.tpbDynamicFont = [UIFont tpbListSubtitle]; traffic.tintColor = [UIColor tpbTextPrimary]; [view addSubview:title]; [view addSubview:traffic]; [title mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(view).offset(14); make.bottom.equalTo(view).offset(-10); make.leading.equalTo(view).offset(4); }]; [traffic mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(title); make.trailing.equalTo(view).offset(-4); }]; } return view; } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return UITableViewAutomaticDimension; } // MARK: --网络请求 - (TPAbstractHandle *)requestClientAppTraffic { if (self.clientAppTrafficRequest) { return self.clientAppTrafficRequest; } NSString *mac = IsEmptyString(self.mac) ? self.appClientDetailTraffic.clientMac : self.mac; TPAbstractHandle * handle; if (StaticsClientDetailVCTypeDefault == self.currentVCType) { handle = [[TPSDNControllerClient currentInstance].currentSite.applicationAnalyticComponent requestClientAppTrafficWithStartTime:self.canlendarStartTime endTime:self.canlendarEndTime currentPage:self.currentPage categories:self.categories.categoryTraffics mac:mac]; } else { handle = [[TPSDNControllerClient currentInstance].currentSite.v6SiteDashboardComponent requestClientAppTrafficWithStartTime:self.canlendarStartTime endTime:self.canlendarEndTime currentPage:self.currentPage mac:mac]; } self.clientAppTrafficRequest = handle; TPWeakSelf [self showWaitingToastView]; [self.clientAppTrafficRequest addCompletionOnMainThread:^(TPHandleResult * _Nonnull result) { TPStrongSelf [_self dismissToastViewWithCompleteBlock:nil]; if (result.success) { if (StaticsClientDetailVCTypeDefault == self.currentVCType) { _self.clientAppsTraffic = [[TPSDNControllerClient currentInstance].currentSite.applicationAnalyticComponent.clientAppsTraffic copy]; _self.totalRow = (int)_self.clientAppsTraffic.totalRows; } else { _self.clientAppsTraffic = [[TPSDNControllerClient currentInstance].currentSite.v6SiteDashboardComponent.clientAppsTraffic copy]; _self.totalRow = (int)_self.clientAppsTraffic.totalRows; } } _self.clientAppTrafficRequest = nil; }]; return self.clientAppTrafficRequest; } - (void)handleHeaderRefresh { DDLogDebug(@"加载第一页数据..."); self.currentPage = 1; [self tpbShowWaitingToast]; TPWeakSelf [[self requestClientAppTraffic] addCompletionOnMainThread:^(TPHandleResult * _Nonnull result) { TPStrongSelf [_self tpbDismissWaitingToast]; [_self buildHeaderView]; [_self reloadView]; }]; } - (void)loadMorePageData { DDLogDebug(@"加载更多页数据..."); self.currentPage ++; TPWeakSelf; [[self requestClientAppTraffic] addCompletionOnMainThread:^(TPHandleResult * _Nonnull result){ TPStrongSelf; if (result.success) { [_self reloadView]; [_self updateFooterStatus]; } }]; } - (void)updateFooterStatus { if (self.clientAppsTraffic.clientAppTrafficList.count < self.totalRow) { [self.tableView.mj_footer endRefreshing]; [self.tableView.mj_footer resetNoMoreData]; } else { [self.tableView.mj_footer endRefreshingWithNoMoreData]; } } - (TPAbstractHandle *)requestCategories { if (self.categoriesRequest) { return self.categoriesRequest; } self.categoriesRequest = [[TPSDNControllerClient currentInstance].currentSite.applicationAnalyticComponent requestCategoriesWithStartTime:self.canlendarStartTime endTime:self.canlendarEndTime]; TPWeakSelf [self.categoriesRequest addCompletionOnMainThread:^(TPHandleResult * _Nonnull result) { TPStrongSelf if (result.success) { _self.categories = [[TPSDNControllerClient currentInstance].currentSite.applicationAnalyticComponent.categories copy]; } _self.categoriesRequest = nil; }]; return self.categoriesRequest; } - (TPAbstractHandle*)requestConnectedClientListWithMac:(nullable NSString *)mac { if (self.requestConnectedClientListHandle) { return self.requestConnectedClientListHandle; } if(![SDNPermissionTool shareInstance].isSupportSiteClientManagerRequest) { return nil; } self.requestConnectedClientListHandle = [[TPSDNControllerClient currentInstance].currentSite.clientComponent getAllClientListWithCurrentPage:1 andSearchKey:self.mac andsearchField:[self.searchFieldDic copy] andFiltersHealth:TPSDNClientHealthTypeUnknown andSortsType:nil isAsc:NO]; TPWeakSelf; [self.requestConnectedClientListHandle addCompletionOnMainThread:^(TPHandleResult * _Nonnull result) { TPStrongSelf; if (result.success) { _self.dmClientArray = [[TPSDNControllerClient currentInstance].currentSite.clientComponent.allClientCurrentPageList mutableCopy]; } }]; return self.requestConnectedClientListHandle; } - (NSMutableArray<DMSDNSiteClient *> *)dmClientArray { if (!_dmClientArray) { _dmClientArray = [NSMutableArray array]; } return _dmClientArray; } - (UITableView *)tableView { if (!_tableView) { _tableView = [TPBCommonTableHelper createKeyboardAvoidingTableViewWithDelegate:self andDataSource:self]; // _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped]; // _tableView.delegate = self; // _tableView.dataSource = self; // _tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine; // _tableView.separatorInfo.separatorStyle = TPTableViewSeparatorSectionStyle; // _tableView.scrollEnabled = YES; // _tableView.backgroundColor = [UIColor tpbBackground]; [_tableView registerClass:SDNStaticClientDetailCell.class forCellReuseIdentifier:kSDNStaticClientDetailCellIdentifier]; _tableView.showsVerticalScrollIndicator = NO; } return _tableView; } - (SDNDashboardSelectTimeView *)selectedTimeView { if (!_selectedTimeView) { _selectedTimeView = [SDNDashboardSelectTimeView new]; TPWeakSelf _selectedTimeView.handleTimeInfo = ^{ TPStrongSelf [_self clickSelectDateRange]; }; _selectedTimeView.hidden = self.currentVCType == StaticsClientDetailVCTypeV6; } return _selectedTimeView; } - (UIRefreshControl *)refreshControl { if (!_refreshControl) { _refreshControl = [[UIRefreshControl alloc]init]; _refreshControl.tintColor = [UIColor grayColor]; [_refreshControl addTarget:self action:@selector(handleHeaderRefresh) forControlEvents:UIControlEventValueChanged]; } return _refreshControl; } - (BOOL)isControllerV6 { return [[TPSDNControllerClient currentInstance].negotiateComponent supportForComponent:DMSDNComponentsdnV6 ForVersionCode:1]; } @end
最新发布
12-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值