ColinEberhardt / VCTransitionsLibrary

A collection of iOS7 animation controllers and interaction controllers, providing flip, fold and all kinds of other transitions.
Other
4.55k stars 617 forks source link

Add a delegate to signal animation completion #6

Open ghost opened 11 years ago

ghost commented 11 years ago

Hi Colin,

I just finished working on the chapter about Custom transitions, so I was very surprised (and happy) to see that this library in CocoaControls was in fact yours ! Thanks for this awesome library :-)

I would like to implement a "fold" transition with a TabBarController with 2 tabs. But I would like each tab to have a distinct color when selected. Unfortunately, the horizontal swipe does not go through:

so I don't have a chance to set self.view.tintColor to the right color.

Is there a way to set the toVC tab tintColor when using an horizontal swipe ?

Thanks Frederic

ColinEberhardt commented 11 years ago

Hi FredddyF,

Glad you liked the book - and yes ... I have been busy!

Interactive transitions with tab bar controllers have cause me a few headaches as well. I have also found that the delegate methods are not 'fired' when used with interaction controllers. For this reason, in my example code I use key-value-observing on the properties of the tab bar controller.

After some more testing, I think the technique I a using is still intermittent. I have made a few minor tweaks, and pushed to this branch here:

https://github.com/ColinEberhardt/VCTransitionsLibrary/tree/tab-bar-interactions

This should be ore reliable.

To set your tint colour, look at the code here:

https://github.com/ColinEberhardt/VCTransitionsLibrary/blob/tab-bar-interactions/TabBarDemo/TabBarDemo/TabBarViewController.m#L44

Use KVO on the selectedViewController property. This should change for both interactive and non-interactive transitions.

Hope the helps.

ghost commented 11 years ago

Thanks a lot for your quick answer, I'll try this out right away ! I must say I'm a big fan of your tutorials, I learned a lot with your tutorial about a to-do list like Clear, and this one about Custom transitions gave me new ideas for my apps !

Thanks !!

Cordialement, Frédéric

Le 1 oct. 2013 à 07:37, ColinEberhardt notifications@github.com a écrit :

Hi FredddyF,

Glad you liked the book - and yes ... I have been busy!

Interactive transitions with tab bar controllers have cause me a few headaches as well. I have also found that the delegate methods are not 'fired' when used with interaction controllers. For this reason, in my example code I use key-value-observing on the properties of the tab bar controller.

After some more testing, I think the technique I a using is still intermittent. I have made a few minor tweaks, and pushed to this branch here:

https://github.com/ColinEberhardt/VCTransitionsLibrary/tree/tab-bar-interactions

This should be ore reliable.

To set your tint colour, look at the code here:

https://github.com/ColinEberhardt/VCTransitionsLibrary/blob/tab-bar-interactions/TabBarDemo/TabBarDemo/TabBarViewController.m#L44

Use KVO on the selectedViewController property. This should change for both interactive and non-interactive transitions.

Hope the helps.

— Reply to this email directly or view it on GitHub.

ghost commented 11 years ago

Colin,

Just to give you an update : I tried to set the tab tintColor in the KVO on selectedViewController property. Unfortunately, what happens is that the selectedViewController property changes as soon as the gesture is initiated ... which changes the icon color of the "from tab" instead of the "to tab" :

Tapped on the first tab : Beer is orange : good :

Tapped on the second tab : Wine is red : good

Swiped to the right : Wine is orange : not so good :-)

The thing is : I wouldn't want to mess with the animationController or InteractiveController classes, they are supposed to be independent from the TabBarController ...

Also, the following line in CEHorizontalSwipeInteractionController.m has a problem : (method handleGesture:)

} else { if (currentIndex + 1 > 0) { self.interactionInProgress = YES; _viewController.tabBarController.selectedViewController = _viewController.tabBarController.viewControllers[currentIndex - 1]; } }

If the current VC is the first one in the viewControllers array, the index is 0 and this will cause a crash. The correct condition would be if (currentIndex > 0)

Cordialement, Frédéric

Le 1 oct. 2013 à 07:37, ColinEberhardt notifications@github.com a écrit :

Hi FredddyF,

Glad you liked the book - and yes ... I have been busy!

Interactive transitions with tab bar controllers have cause me a few headaches as well. I have also found that the delegate methods are not 'fired' when used with interaction controllers. For this reason, in my example code I use key-value-observing on the properties of the tab bar controller.

After some more testing, I think the technique I a using is still intermittent. I have made a few minor tweaks, and pushed to this branch here:

https://github.com/ColinEberhardt/VCTransitionsLibrary/tree/tab-bar-interactions

This should be ore reliable.

To set your tint colour, look at the code here:

https://github.com/ColinEberhardt/VCTransitionsLibrary/blob/tab-bar-interactions/TabBarDemo/TabBarDemo/TabBarViewController.m#L44

Use KVO on the selectedViewController property. This should change for both interactive and non-interactive transitions.

Hope the helps.

— Reply to this email directly or view it on GitHub.

ColinEberhardt commented 11 years ago

Thanks for pointing out that bug (I'll make sure not to merge that branch!)

I agree that the animation / interaction controllers shouldn't be meddled with.

Do you think it would help to add a delegate to the interaction controller that signals when the transition has completed?

ghost commented 11 years ago

Hi Colin

That sounds like a great idea ! I was thinking about a public BOOL property to indicate that the transition was complete, but delegation seems a better method.

I plan to spend some time on this subject on Thursday, looks like a lot of fun !

Thanks

Cordialement, Frédéric

Le 1 oct. 2013 à 22:14, ColinEberhardt notifications@github.com a écrit :

Thanks for pointing out that bug (I'll make sure not to merge that branch!)

I agree that the animation / interaction controllers shouldn't be meddled with.

Do you think it would help to add a delegate to the interaction controller that signals when the transition has completed?

— Reply to this email directly or view it on GitHub.

ghost commented 11 years ago

Hi Colin,

The delegate worked fine !

I created a CEInteractionControllerDelegate protocol (yes, it begins with CE, as a tribute :-)

@protocol CEInteractionControllerDelegate

@optional

@end

I then set this property in the CEBaseInteractionController.h @property (nonatomic, weak) id interactionDelegate;

In the CEBaseInteractionController.m, I added this :

}

Back to the TabBarViewController, I added the following

In initWithCoder: _interactionController.interactionDelegate = self;

Added this method :

pragma mark - Interaction controller delegate

And this one:

Now I still have to finish the challenge for chapter 3 in iOS7 by Tutorials ... back to work :-)

Thanks for your help !

Cordialement, Frédéric

Le 1 oct. 2013 à 22:14, ColinEberhardt notifications@github.com a écrit :

Thanks for pointing out that bug (I'll make sure not to merge that branch!)

I agree that the animation / interaction controllers shouldn't be meddled with.

Do you think it would help to add a delegate to the interaction controller that signals when the transition has completed?

— Reply to this email directly or view it on GitHub.

ColinEberhardt commented 11 years ago

Thanks for letting me know that this idea worked for you.

I've re-opened this issue because I think the delegate is something I should add to VCTransitionsLibrary so that everyone can benefit from this approach.

ghost commented 10 years ago

Hi Colin,

I continued exploring Custom VC transitions, and I came up with 2 new transitions :

The first one looks cool, so I thought I would share it with you, in case you like it ! That's not much, but I feel like I owe you a lot after all you've shared in the tutorials on raywenderlich.com. I'm not sure it works with an interactionController, though ...

The second one is a bit more tricky : I want to zoom in from a collectionView item, until it takes the main spot in a UIViewController.

1 - click on the duck "card"

2 - transiiton : the card "zooms in"

3 - the full image is presented in a UIViewController

That works OK but in order to keep my classes separated, I need to pass the frame that the little card is supposed to reach (forwards transition), and the frame in the collection view that the full image is supposed to reach ... Basically, in the "prepareForSegue", I give the animationController the "from-view" frame in the collectionView (and I know that it should then reach the center of the UIViewController's view), and in an unwind segue, I give the animationController the from- and to- frames for the animation.

And the problem is : if I transition from the collectionView to the UIViewController, then rotate my iPad then go back, the reverse transition fails because my transition kept track of the position it had in the collectionView, but the rotation will cause the VC to give a new layout to the collectionView.

If you could just give me a hint or set me on track about how to "predict" what will the frame of a cell be in the new layout of the collectionView, I'll be more than grateful !

Here are my classes :

AlbumViewController is where the collectionView is, ImageviewController is a UIViewcontroller presenting the image "full screen" and the zoomInAnimationController is my animationController.

Thanks ! Frederic

ColinEberhardt commented 10 years ago

Hi @FredddyF - I'd love to see your transitions, but they have been stripped out of your comment. Perhaps you could commit them to a fork? Or upload them to a gist?

ghost commented 10 years ago

Thanks Colin !

Sorry, I didn't know how to contact you otherwise ! I'm still a github newbie :-)

I created a Fork named "portal animation" to VCTransitionsLibrary.

And here is a link to a repo of my own app on Github : https://github.com/FredddyF/BabyBook-v2--iOS7- (it's stripped of sound files to take less space, but you can still play the animations) I detailed the issue I meet in a new "issue" point.

I'd love to hear your comments !

Thanks

Regards, Frédéric

Le 9 déc. 2013 à 09:53, ColinEberhardt notifications@github.com a écrit :

Hi @FredddyF - I'd love to see your transitions, but they have been stripped out of your comment. Perhaps you could commit them to a fork? Or upload them to a gist?

— Reply to this email directly or view it on GitHub.

ColinEberhardt commented 10 years ago

Hi Frédéric, I've just downloaded that app - it looks awesome!

Do you mind if I add your portal animation to this library? (I'll attribute it to you and link to your GitHub page).

Thanks, Colin E.

ghost commented 10 years ago

Hi Colin,

Sure, I'd be honored ! However, I tried to integrate the portal animation within VCTransitionsLibrary, but it doesn't seem to work well with the interaction controller ... I can't find what's wrong. Maybe I'll check again later ... After I had a fair share of sleep :-)

And if you have an idea about how to determine the position of a collection view cell before it's displayed on screen and after a rotation has occurred, you'd save me a few sleepless nights ;-)

Thanks a lot !

Regards Frederic

Le 10 déc. 2013 à 07:44, ColinEberhardt notifications@github.com a écrit :

Hi Frédéric, I've just downloaded that app - it looks awesome!

Do you mind if I add your portal animation to this library? (I'll attribute it to you and link to your GitHub page).

Thanks, Colin E.

— Reply to this email directly or view it on GitHub.

ColinEberhardt commented 10 years ago

Thanks Freddy, I've added your Portal animation. I had to make a few changes in order for it to reverse properly. You can see them here:

https://github.com/ColinEberhardt/VCTransitionsLibrary/commits/master/AnimationControllers/CEPortalAnimationController.m

Thanks again :-)

ghost commented 10 years ago

Great, thanks !!

Cordialement, Frédéric

Le 10 déc. 2013 à 23:31, ColinEberhardt notifications@github.com a écrit :

Thanks Freddy, I've added your Portal animation. I had to make a few changes in order for it to reverse properly. You can see them here:

https://github.com/ColinEberhardt/VCTransitionsLibrary/commits/master/AnimationControllers/CEPortalAnimationController.m

Thanks again :-)

— Reply to this email directly or view it on GitHub.

ghost commented 10 years ago

Hi Colin

I wanted to let you know that I found a workaround for my animation to set an Image from an Image view controller back to its place in a collectionView in an Album View controller.

The issue was :

What I did is :

A bit difficult to explain, so I just updated my project in GitHub here : https://github.com/FredddyF/BabyBook-v2--iOS7-

Thanks for your help and your tutorials, they are an endless source of inspiration, hints and useful tricks ;-)

Best regards, Frédéric

Le 10 déc. 2013 à 23:37, Frédéric ADDA fredadda@gmail.com a écrit :

Great, thanks !!

Cordialement, Frédéric

Le 10 déc. 2013 à 23:31, ColinEberhardt notifications@github.com a écrit :

Thanks Freddy, I've added your Portal animation. I had to make a few changes in order for it to reverse properly. You can see them here:

https://github.com/ColinEberhardt/VCTransitionsLibrary/commits/master/AnimationControllers/CEPortalAnimationController.m

Thanks again :-)

— Reply to this email directly or view it on GitHub.