zoukankan      html  css  js  c++  java
  • iOS开发:视图生命周期

    iOS应用的视图状态分为以下几种

    • 在viewcontroller的父类UIViewController中可以看到如下代码,通过重写不同的方法对操作视图渲染。
    @available(iOS 2.0, *)
    public class UIViewController{
     
       public func viewDidLoad() // Called after the view has been loaded. For view controllers created in code, this is after -loadView. For view controllers unarchived from a nib, this is after the view is set.
       public func viewWillAppear(animated: Bool) // Called when the view is about to made visible. Default does nothing
        public func viewDidAppear(animated: Bool) // Called when the view has been fully transitioned onto the screen. Default does nothing
        public func viewWillDisappear(animated: Bool) // Called when the view is dismissed, covered or otherwise hidden. Default does nothing
        public func viewDidDisappear(animated: Bool) // Called after the view was dismissed, covered or otherwise hidden. Default does nothing
    public func didReceiveMemoryWarning() // Called when the parent application receives a memory warning. On iOS 6.0 it will no longer clear the view by default.
     
    }
      • viewDidLoad():视图被加载到内存中时调用viewDidLoad方法,在该方法中可对视图上布局进行调整
      • viewWillAppear():视图可见前
      • viewDidAppear():视图已经可见,页面渲染完成后可以加载一些控件动画
      • viewWillDisappear():视图失去焦点前
      • viewWillDidDisappear():视图失去焦点后
      • didReceiveMemoryWarning():在iOS 6之后可使用此方法释放内存,包括视图控制器中的一些成员变量
  • 相关阅读:
    安装elasticsearch 和 kibana
    docker 安装 nignx 并将对应配置文件映射
    linux 操作笔记
    docker 一些常用的命令手记
    c# 异步 多线程
    从零开始在.net中使用Nhibernate对数据库进行操作详细步骤(20121128)
    NHibernate框架的HQL增删改查
    2012年11月19日 利用wifiap简单实现Wifi无线Web认证
    逻辑结构和物理结构
    日志
  • 原文地址:https://www.cnblogs.com/tonge/p/4959390.html
Copyright © 2011-2022 走看看