kawoou / KWDrawerController

Drawer view controller that easy to use!
MIT License
157 stars 32 forks source link

drawerController is null in viewWillDisappear and viewDidDisappear #21

Closed Serproger closed 6 years ago

Serproger commented 6 years ago

Extension property drawerController of UIViewController returns nil when I'm trying to access it in viewWillDisappear and viewDidDisappear methods of my view controller. Could you please explain this behaviour if it's correct or fix it if there is some bug?

kawoou commented 6 years ago

The situation is not reproduced. Can you tell me what circumstances?

Serproger commented 6 years ago

This issue can be observed when UINavigationController is located inside DrawerController, I have controllers A and B in navigation stack and I press back button in B. ViewWillDisappear and ViewDidDisappear of B will be called, but in both of them drawerController property is equal to nil. If necessary, I'll prepare sample project.

Serproger commented 6 years ago

UPD. Sorry, in this case the problem doesn't reproduce. I'll prepare another sample sample.

kawoou commented 6 years ago

If that's what I understand:

DrawerController <- UINavigationController
  UINavigationController <- A
  UINavigationController <- B

Since A and B are not managed directly by DrawerController, nil value is correct.

However, the drawerController property of the UINavigationController will be not nil.

Serproger commented 6 years ago

But in other lifecycle methods drawerController is not nil...

kawoou commented 6 years ago

What is "other lifecycle"?

Serproger commented 6 years ago

for example, viewDidLoad.

kawoou commented 6 years ago

I extended the range of drawerController property. #25 Is there a problem now?

Serproger commented 6 years ago

drawertest1.zip

Please see controller InnerContentController1 in this sample. drawerController is not nil in viewWillDisappear but it is nil in viewDidDisappear.

Serproger commented 6 years ago

You should press button "GO", then button "Button", then press back button in navigation controller to reproduce.

kawoou commented 6 years ago

I have tested the code. In viewDidDisappear, it is normal for the drawerController variable to be nil. Because there is no parentViewController at the time when viewDidDisappear is called.

Serproger commented 6 years ago

OK, maybe it's the feature, not bug :)

Please update package in Cocoapods.