52inc / Pulley

A library to imitate the iOS 10 Maps UI.
https://cocoapods.org/pods/Pulley
MIT License
2.02k stars 265 forks source link

collapsedDrawerHeight & PulleyDrawerViewControllerDelegate stuff not called at startup? #254

Closed jtayler closed 6 years ago

jtayler commented 6 years ago

I have a project based on the Demo and somehow the delegate system has become disconnected and I can't see how the Demo project sets it.

In my DrawerViewController I now manually set the pulleyViewController?.delegate = self

Which seems already too late in the wire up process? I DO get calls for the drawer changing size, but I did not get any calls to the PulleyDrawerViewControllerDelegate stuff like collapsedDrawerHeight at startup.

The effect is that things like the bottomSafe area are not set, nor is the gripperView's constraint deactivated on iPad etc.

I would have figured to find a wire up in IB but when I search through the Demo project, I actually don't see where this delegate is set at all!

Thanks for anyone who can help clear my confusion!

amyleecodes commented 6 years ago

In my DrawerViewController I now manually set the pulleyViewController?.delegate = self

You shouldn’t do this. It’ll cause double delivery of delegate callbacks. The various delegate methods are called automatically on the primary/drawer view controllers as long as they implement the appropriate delegate (and mark themselves as such). These aren’t manually set, as they are tied directly to the view controller currently being used and must “change” simultaneously as the view controller is set. They each have a specific protocol they implement, not just the regular delegate protocol. The delegate property is there in case you need an external object to also be notified of changes.

Older versions of Pulley didn’t deliver updates of those values upon startup. The current version does, I believe. Make sure you’re using the most recent version and see if that fixes it.

jtayler commented 6 years ago

wow, ok! thanks - I removed the additional delegate setting there and pulled new code from my demo app in the PulleyViewController.swift file and since there were no other diffs, I moved that only and sure enough things are better but perhaps I should further update or perhaps I broke something while fussing with IB settings?

I note these artifacts: the bottom box area on landscape or pad is now working more properly with margin from the bottom now working -- but the gripper is not moving to the bottom area as it should - for iPhoneX it it not given that extra-additional space there at the bottom that is so nicely demonstrated by the Demo app.

do you think that suggests mistakes in my storyboard that I introduced while fussing or perhaps I need adjustments or updates I did not get by updating that one file?

amyleecodes commented 6 years ago

Depending on how old of a version of Pulley you had, you may be working with a version that pre-dates iPhone X / safe area support.

I would recommend including Pulley as a CocoaPod, and building your app in a new project rather than building around the sample app. The sample app is updated to take advantage of new APIs to do tricks like Safe Areas, gripper moving, etc. Your older copy of the sample app code may not be doing these things (or may not be using the current Pulley APIs).

You also could’ve broken something in Storyboards, or more likely, in your drawer view controller code (broken, or not using latest APIs).

If it works in the current sample project, then you should be able to do it in your app without issue (unless there have been code changes to Pulley, etc. in your local copy of Pulley).

jtayler commented 6 years ago

I see, yes thanks, does it matter that I embedded my drawer tableview vc into a navigation controller?

amyleecodes commented 6 years ago

Yes. That means that the navigation controller is the drawer view controller. You’ll need to implement delegate methods there, or implement the delegate methods in a way that they proxy them to the currently visible view controller in your navigation controller.

jtayler commented 6 years ago

ah, ok, that makes sense, I'll make a custom UINavigationController class and implement those delegate methods there as it seems that would be needed for this design. Meantime, I will regenerate the project based on the pods project which I'd guess is the easiest to keep updated.