naldikt / NXSS

NX Style Sheet - customize your UI using CSS-like files & conventions.
1 stars 0 forks source link

NapX FSP #21

Closed naldikt closed 8 years ago

naldikt commented 8 years ago

Kotzzi said: Open the FSP, the nav bar is transparent, close it, open it again and it will be gray forever… just on iOS8

naldikt commented 8 years ago

This isn't NXSS bug.

This is skyway bug.

In order to know why it's not updating, we need to know how it works: • In FSPVC.viewDidLoad() we set its navigationBar.nxssClass.
• That way when UINavigationBar is entering the window, it'll apply the nxssClass set by FSPVC. • This works first time just fine. • Then FSP is dismissed, and to be redisplayed again on the second open. • The issue is: FSPVC is not deallc'ed when it's dismissed, but its NavigationController is. This caused FSPVC.viewDidLoad() is not called when displayed a second time with a brand new NavigationController.navigationBar. Hence on the second display the navBar is showing default state from nxss.

Confusion: I moved the setting of nxssClass to viewWillAppear and it worked on iOS 9, but not on iOS 8. What happened? I'm guessing the way iOS initialize UINavigationBar is different in iOS 8 vs 9. I bet in iOS 9, it's calling FSPVC.viewWillAppear first prior to UINavigationBar.didMoveToWindow (which causes the setting of nxss to be executed first). Whereas in iOS 8, it's calling UINavigationBar.didMoveToWindow first prior to FSPVC.viewWillAppear (which causes the setting to be executed later after applyNXSS() is called internally).

Here's 2 options to fix (either should work:

• Figure out why FSPVC is not dealloc'ed when it's dismissed. There's gotta be retain cycle somewhere. Both FSPVC and NavigationController must have the same lifecycle in order for this to work. I think this is the ideal solution.

• Turn a blind eye on this retain cycle - it may not matter since there's always one FSP anyway. A quick fix will be to call navigationBar.applyNXSS() after you set the NXSSClass in viewWillAppear: