Latest 0.2.0
Homepage https://github.com/T-Pham/ViewDidAppearFirstTime
License MIT
Platforms ios 10.0
Authors

The library lets you know whether your UIViewController subclasses’ viewWillAppear and viewDidAppear are being called for the first time.
It adds the following methods:

  • viewWillAppearFirstTime(_:): called when viewWillAppear the first time.
  • viewWillAppearAgain(_:): called when viewWillAppear the second time on.
  • viewDidAppearFirstTime(_:): called when viewDidAppear the first time.
  • viewDidAppearAgain(_:): called when viewDidAppear the second time on.

Before:

import UIKit

class ViewController: UIViewController {

    var firstTime = true

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        if firstTime {
            //viewWillAppear first time
        } else {
            //viewWillAppear again
        }
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        if firstTime {
            //viewDidAppear first time
            firstTime = false
        } else {
            //viewDidAppear again
        }
    }
}

After:

import UIKit
import ViewDidAppearFirstTime

//in AppDelegate: UIViewController.activateFirstAppearance()

class ViewController: UIViewController, FirstAppearance {

    func viewWillAppearFirstTime(_ animated: Bool) {
        //viewWillAppear first time
    }

    func viewWillAppearAgain(_ animated: Bool) {
        //viewWillAppear again
    }

    func viewDidAppearFirstTime(_ animated: Bool) {
        //viewDidAppear first time
    }

    func viewDidAppearAgain(_ animated: Bool) {
        //viewDidAppear again
    }
}

Installation

pod 'ViewDidAppearFirstTime'

License

ViewDidAppearFirstTime is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "ViewDidAppearFirstTime",
    "version": "0.2.0",
    "summary": "Lets you know whether your `UIViewController` subclasses' `viewWillAppear` and `viewDidAppear` are being called for the first time.",
    "description": "ViewDidAppearFirstTime lets you know whether your `UIViewController` subclasses' `viewWillAppear` and `viewDidAppear` are being called for the first time.",
    "homepage": "https://github.com/T-Pham/ViewDidAppearFirstTime",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Thanh Pham": "[email protected]"
    },
    "source": {
        "git": "https://github.com/t-pham/ViewDidAppearFirstTime.git",
        "tag": "0.2.0"
    },
    "platforms": {
        "ios": "10.0"
    },
    "source_files": "ViewDidAppearFirstTime/Classes/**/*",
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This