djk12587 / DJKFlipper

Flipboard like animation library
MIT License
51 stars 13 forks source link

Constraints not working properly - Swift 3 #9

Closed Mamtak1811 closed 7 years ago

Mamtak1811 commented 7 years ago

I am using flipper inside a view controller having navigation bar and tab bar. For now, I have a label at the top and an image below in the flipper detail view. Whenever I put top constraints to label in the detail page view (PageTestViewController's IB, as referred to in your example), the view shifts slightly down after loading, during runtime. No shifting happens if I keep the image horizontally and vertically centered and remove the label totally. I am unable to understand what's exactly happening here.

One more issue is that I need to load the flipview only once a button is clicked, not on page load. How to accomplish that?

djk12587 commented 7 years ago

@Mamtak1811 Any chance you can create a sample project that illustrates the problem you are having? I am having trouble picturing how your view hierarchy is set up. I setup what I thought you said, and I couldn't reproduce the issue. I have a tabbarcontroller and one of the tabs has a navcontroller, with a rootviewcontroller. That rootviewcontroller is the flipper view. The pages for the flipper view have a label constrained to the top, and the label does not shift down...

Mamtak1811 commented 7 years ago

Will share a demo project shortly

Mamtak1811 commented 7 years ago

I have uploaded demo project to this link: https://www.dropbox.com/s/ikl5m266cc4on7t/Demo.zip?dl=0

djk12587 commented 7 years ago

@Mamtak1811 thanks for uploading that. There seems to be something funky if you set up the flipperView via constraints. I'll have to look into that. A work around is to remove the flipperview from your TopStoriesScene and turn the viewcontrollers view into a DJKFlipperView. Also be sure to connect the outlet again. Check out the screen shot below.

screenShot

Mamtak1811 commented 7 years ago

I tried that too. It does not work with top constraints in the SportsScene.

djk12587 commented 7 years ago

@Mamtak1811 I see now. It seems creating the pages that flip in the storyboard cause issues. It has something to do with the toplayoutguide being set dynamically.

If you remove the SportsFliperViewController from the storyboard and create a separate .xib for it, it should honor the top constraint correctly.

Mamtak1811 commented 7 years ago

Thanks! That works perfectly fine.

Please also answer this question: I need to load the flipview only once a button is clicked, not on page load. How to accomplish that? I have used reload but it would be better if i do not load it at all on initial load.

djk12587 commented 7 years ago

@Mamtak1811 i'm glad that worked.

I pushed an update 0.1.9 setting the datasource no longer auto refreshes the view. You can set up your datasource and array, but call reload() whenever you want the flipperview to show.