ALOK NAIR thoughts.toString( )

The Inconsistent Order of View Transition Events

You should never write code depending on any particular order of

  • viewWillAppear:
  • viewDidAppear:
  • viewWillDisappear:
  • viewDidDisappear:

calls in any app with more that one kind of view transitions because each kind of view transition has its own order and it may be incompatible with the assumption of your code.

For demonstration I’ll show you the cases of three common view transitions.

  • Navigation

    Normal: (Pushing and popping, interactive or not)

    1. CurrentviewWillDisappear
    2. NewviewWillAppear
    3. CurrentviewDidDisappear
    4. NewviewDidAppear

    Canceled Interactive Popping:

    1. CurrentviewWillDisappear
    2. NewviewWillAppear
    3. NewviewWillDisappear
    4. NewviewDidDisappear
    5. CurrentviewWillAppear
    6. CurrentviewDidAppear
  • Page Scrolling (UIPageViewControllerTransitionStyleScroll)

    Normal:

    1. NewviewWillAppear
    2. CurrentviewWillDisappear
    3. NewviewDidAppear
    4. CurrentviewDidDisappear

    Canceled Interactive Scrolling:

    1. NewviewWillAppear
    2. CurrentviewWillDisappear
    3. CurrentviewWillAppear
    4. CurrentviewDidAppear
    5. NewviewWillDisappear
    6. NewviewDidDisappear
  • Page Curling (UIPageViewControllerTransitionStylePageCurl)

    Normal:

    1. NewviewWillAppear
    2. CurrentviewWillDisappear
    3. CurrentviewDidDisappear
    4. NewviewDidAppear

    Canceled Interactive Curling:

    1. NewviewWillAppear
    2. CurrentviewWillDisappear
    3. NewviewWillDisappear
    4. CurrentviewWillAppear
    5. NewviewDidDisappear
    6. CurrentviewDidAppear

As you can see:

  • New view’sviewWillAppearmay be called before or after current view’sviewWillDisappear.
  • New view’sviewDidAppearmay be called before or after current view’sviewDidDisappear.
  • For interactive canceling, new view’sviewDidDisappearis not balanced withviewDidAppear— there is noviewDidAppearbetweenviewWillAppearandviewWillDisappear.
  • Of course, for the same view,viewWillAppearis always beforeviewDidAppearandviewWillDisappearis always beforeviewDidDisappear, if only both are gotten called — see point 3.
  • The only certain order between current view and new view is that current view’sviewWillDisappearis before new view’sviewDidAppearand new view’sviewWillAppearis before current view’sviewDidDisappear, but if only both are gotten called — see point 3.

Continue reading...

Set up a blog with Jekyll and Github Pages - Part 2

Continuing from where I left off in my previous post, here’s how you can jazz-up your Jekyll blog:

Bootstrap

The standard Jekyll scaffolding is just one way to bootstrap your jekyll blog. Some might find it basic, and would expect a little more to be available out-of-the-box. Fortunately, there are a few other ways in which you could bootstrap a more functional blog.


Continue reading...

Set up a blog with Jekyll and Github Pages - Part 1

In my previous post, I wrote about some of my expectations from a blogging platform, and reasons why I was excited about Jekyll & Github Pages.

Here, I’ll give you a quick run-through of how to get a blog up and running in a matter of few hours.


Continue reading...