-(void)viewWillAppear:(BOOL)animated,- (void)viewDidLoad 的区别。

viewwillappear是每次视图控制器的视图出现前执行的代码。 (进入每次都会执行)

而viewdidload是每次视图控制器载入是执行的代码。(只执行一次)

比如说:当a视图控制器的视图第一次出现是两个都要执行,但当a被push后有pop回来时,只有viewwillappear执行。


iOS视图控制对象生命周期-init、viewDidLoad、viewWillAppear、viewDidAppear、viewWillDisappear、viewDidDisappear的区别及用途

init-初始化程序

viewDidLoad-加载视图

viewWillAppear-UIViewController对象的视图即将加入窗口时调用;

viewDidApper-UIViewController对象的视图已经加入到窗口时调用;

viewWillDisappear-UIViewController对象的视图即将消失、被覆盖或是隐藏时调用;

viewDidDisappear-UIViewController对象的视图已经消失、被覆盖或是隐藏时调用;

viewVillUnload-当内存过低时,需要释放一些不需要使用的视图时,即将释放时调用;

viewDidUnload-当内存过低,释放一些不需要的视图时调用。



分析下面代码的逻辑,但这个页面完成最后设置时,需要解决下面的bug bug信息: Bug 1174015 - 【quick setup】iOS standalone添加ap,quick setup最后一步summary页控件依然显示为Next,安卓为“Confirm”引导更合理 (edit) 基本信息 ► 审核区域▼ Status: ASSIGNED (edit) Importance: major (edit) Bug的类别: UI (edit) 出现频率: 必然 (edit) 能否恢复: --- (edit) 测试拓扑: (edit) 陪测设备: (edit) 重现步骤: iOS standalone添加ap,quick setup到最后一步summary页,观察 (edit) 测试结果: 控件依然显示为Next (edit) 期望结果: 显示为confirm (edit) 问题产品: (edit) 对比测试: Android显示为confirm (edit) 问题分析: 请分析 (edit) 影响评估: 双端不一致 (edit) 代码: // // StandaloneQuickSetupSummaryViewController.m // Omada // // Created by zhuangqiuxiong on 2018/1/8. // Copyright © 2018年 TP-Link. All rights reserved. // #import "StandaloneQuickSetupSummaryViewController.h" #import "VMSLQuickSetupSummary.h" #import "StandaloneQuickSetupApplySettingsViewController.h" #import "TPSLQuickSetupUserAbstractLayer.h" #import "standaloneQuickSetupFlexibleBar.h" @interface StandaloneQuickSetupSummaryViewController ()<UITableViewDelegate> @property (nonatomic, strong) UITableView *tableView; @property (nonatomic, strong) VMSLQuickSetupSummary *vmTableViewDataSource; @property (nonatomic, strong) StandaloneQuickSetupFlexibleBar *flexibleBar; @property (nonatomic, strong) UIButton *nextButton; @property (nonatomic, assign) BOOL isForGateway; @end @implementation StandaloneQuickSetupSummaryViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. [self setupNavigationItem]; [self buildTableView]; [self buildFlexibleBar]; } - (void)buildTableView { self.tableView = [TPBCommonTableHelper createKeyboardAvoidingTableViewWithDelegate:self andDataSource:nil]; // self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped]; [self.view addSubview:self.tableView]; // self.tableView.delegate = self; // self.tableView.estimatedRowHeight = 72; // self.tableView.estimatedSectionHeaderHeight = 0; // self.tableView.estimatedSectionFooterHeight = 0; // self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; // self.tableView.separatorInfo.separatorStyle = TPTableViewSeparatorDetailStyle; // self.tableView.tableFooterView = [[UIView alloc] init]; // self.tableView.backgroundColor = [UIColor tpbBackground]; self.vmTableViewDataSource = [[VMSLQuickSetupSummary alloc] init]; self.tableView.dataSource = self.vmTableViewDataSource; [self.vmTableViewDataSource registerClassInTableView:self.tableView]; UIButton *nextButton = [[UIButton alloc] init]; if (nextButton) { [self.view addSubview:nextButton]; [nextButton setBackgroundColor:[UIColor tpbPrimary]]; nextButton.layer.cornerRadius = 22; [nextButton setTitle:gStandaloneQuickSetup.standaloneQuickSetupSetAccountNavRightButton forState:UIControlStateNormal]; nextButton.titleLabel.font = [UIFont tpr20Regular]; nextButton.titleLabel.textColor = [UIColor tpbTextWhite]; [nextButton addTarget:self action:@selector(next) forControlEvents:UIControlEventTouchUpInside]; TPWeakSelf; [nextButton mas_makeConstraints:^(MASConstraintMaker *make) { TPStrongSelf; make.leading.mas_equalTo(_self.view).offset(20); make.trailing.mas_equalTo(_self.view).offset(-20); make.height.equalTo(@(44)); make.bottom.equalTo(self.mas_tpSafeAreaLayoutGuide).offset(-8); }]; self.nextButton = nextButton; } TPWeakSelf; [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { TPStrongSelf; make.top.leading.trailing.equalTo(self.mas_tpSafeAreaLayoutGuide); make.bottom.equalTo(self.nextButton.mas_top).offset(-2); }]; } - (void)buildFlexibleBar { CGFloat maxBarHeight = kFlexibleBar_MinHeight + 50.0f; CGFloat minBarHeight = kFlexibleBar_MinHeight; self.flexibleBar = [[StandaloneQuickSetupFlexibleBar alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, maxBarHeight) andMaximumBarHeight:maxBarHeight andMinimumBarHeight:minBarHeight andElasticMaximumHeightAtTop:NO andViewController:self andScrollView:self.tableView]; if ( self.flexibleBar ) { [self.view addSubview:self.flexibleBar]; self.flexibleBar.titleString = gStandaloneQuickSetup.standaloneQuickSetupSummaryNavTitle; [self.flexibleBar setupSubViewsAndLayoutAttributes]; // self.flexibleBar.backgroundColor = [UIColor tpbBackground]; } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; self.tpbPrivacyProtectionEnabled = YES; [self.vmTableViewDataSource reloadData]; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; } #pragma mark - TableView Delegate - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { // return 40; return UITableViewAutomaticDimension; } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { return [self.vmTableViewDataSource viewForSectionHeaderInSection:section]; } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { // return 0.01; return TPBDesign.list.sectionFooterHeight; } - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { return [UIView new]; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; } #pragma mark - 导航栏相关 - (void)setupNavigationItem { // [self setNavigationBarTitle:gStandaloneQuickSetup.standaloneQuickSetupSummaryNavTitle]; // [self.tpNavigationController setNavigationBarTitleFont:[UIFont tpr20Regular] andColor:[UIColor tpbTextPrimary]]; self.isNavigationBarTransparent = YES; UIBarButtonItem *leftBarButtonItem = [self createBarButtonItemItemWithStyle:TPViewControllerBarButtonItemStyleBackInBlue andTarget:self andAction:@selector(back)]; self.navigationItem.leftBarButtonItem = leftBarButtonItem; } - (void)back { [self.tpNavigationController popViewControllerAnimated:YES]; } - (void)next { TPWeakSelf; [self showWaitingToastView]; [[[ALStandaloneDeviceContext currentInstance] checkLoginStatus] addCompletionOnMainThread:^(TPHandleResult *result) { TPStrongSelf; [_self dismissToastViewWithCompleteBlock:^{ if (result.success) { if (self.isForGateway) { // 跳转到Gateway页面 [_self.tpNavigationController pushViewControllerWithCustomAnimation:[[StandaloneQuickSetupApplySettingsViewController alloc] initForGateway:self.isForGateway] animated:YES]; } else { // 跳转到EAP页面 [_self.tpNavigationController pushViewControllerWithCustomAnimation:[[StandaloneQuickSetupApplySettingsViewController alloc] init] animated:YES]; } } else { DDLogInfo(@"检查QuickSetup前置条件不满足"); [self showCommonFailedToastView]; } }]; }]; } - (void)orientationChangeAction { //横屏模式下 if (self.orientation == TPBInterfaceOrientationRight || self.orientation == TPBInterfaceOrientationLeft) { CGFloat maxBarHeight = kFlexibleBar_MinHeight + 50.0f; self.flexibleBar.frame = CGRectMake(0, 0, MAX(kScreen_Width, kScreen_Height), maxBarHeight); } //竖屏模式下 else { CGFloat maxBarHeight = kFlexibleBar_MinHeight + 50.0f; self.flexibleBar.frame = CGRectMake(0, 0, MIN(kScreen_Width, kScreen_Height), maxBarHeight); } } // MARK: 工具函数 - (BOOL)isForGateway { return [TPStandaloneClient currentInstance].discoveredDevice.isGateway; } @end
最新发布
12-06
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值