yackle / CLImageEditor

MIT License
2.22k stars 574 forks source link

Determine if editor has opened/closed a tool #146

Closed mpinkston closed 8 years ago

mpinkston commented 8 years ago

I'd like to request a way to know when the editor has gone into edit mode; as in when a user selects a tool (unless one already exists, which I've missed).

My use-case scenario is that I've initialized and added a bunch of editors to a UIPageViewController to allow editing multiple images one after another. This works quite well. However, some of the tools have sliders which can be tricky to use when the UIPageViewController's gesture recognizer is still enabled.

I'd like to disable the UIPageViewController's gesture recognizer when a tool has been selected, but am not sure how best to achieve this. Currently I've added a KVO to the navigationBar's "transform" property to watch for this, but that seems messy.

So, what do you think about adding a delegate method that fires when a tool is opened/closed?

yackle commented 8 years ago

How about like this:

 [editor addObserver:self forKeyPath:@"currentTool" options:NSKeyValueObservingOptionNew context:nil];
mpinkston commented 8 years ago

Thanks @yackle, there you have it. It just didn't click to try observing "currentTool" directly for some reason. I'm using Swift and RxSwift to set up my observers, so editor.rx_observe(AnyObject.self, "currentTool").subscribeNext... does the trick for me. I appreciate your help.