matthewcheok / MCPanelViewController

Drop-in panel control for iOS with blurring background and screen-edge activation gestures.
MIT License
324 stars 25 forks source link

Make parts of screen that aren't covered by slideout interactive and tappable #3

Closed jlr closed 11 years ago

jlr commented 11 years ago

Hi,

Thanks for the excellent slideout widget. It's a really huge boost to the app I'm building and I'm very grateful that you've released it.

I have been studying your code for over a week now (I think I found it the day it was released - Oct 5?). I can't seem to figure out something that ought to be trivial. I want slideouts to only obscure the portion of the screen which they actually cover, so that you can still tap any other part of the screen and interact with it normally.

I've disabled the backgroundButton property and the shadow that appears over the remainder of the screen when you slide out, and also looked in detail at various CGRect and CGBounds properties to see if I'm missing any views that cover the whole screen. But I'm just not seeing what's preventing tap gestures to go through when a MCPanelView is slid out.

Could you give me some form of pointer towards solving this? It would be extremely helpful to me.

Thanks again for releasing such high quality and beautiful code. This slideout widget makes a big difference for me.

matthewcheok commented 11 years ago

That's because the MCPanelViewController's view itself is consuming the touches. This view is transparent and completely covers the parent view controller (presenting view controller) and your presented view controller's view is then added as a subview to it.

One possible solution is replace this view with a subclass that overwrites the - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event method to allow touches not inside the view of the presented view controller (rootViewController property) to pass through.

jlr commented 11 years ago

Thanks very much. That did it.

lemak5 commented 10 years ago

Hi, I tried to implement this solution in your example but I did not succeed. Can you help me? Thank you in advance

matthewcheok commented 10 years ago

Can you elaborate how you have implemented the solution?

lemak5 commented 10 years ago

Hi Matthewcheok,

Thanks for your answer :) I am a beginner in iOS programming. I certainly made ​​mistakes. Here is my implementation: I created a subclass of UIView class: @interface MCCustomView : UIView with:

In the initWithRootViewController method of MCPanelViewController, I added: object_setClass(self.view, [MCCustomView class]);

I also tried to change the frame properties and bounds of the view without success.

PS : sorry for my english!

lemak5 commented 10 years ago

Small addition:

I deleted also all references to: shadowView, imageView & backgroundButton

matthewcheok commented 10 years ago

You can overwrite - (void)loadView and specify self.view = [[MCCustomView alloc] init] to specify the class to be used for the view controller.

lemak5 commented 10 years ago

The result is the same as my implementation. The pointInside's method is called (twice) but the buttons called "Left" and "Push view controller" remain inactive :( Should i resize the frame of the MCPanelViewController's view ?

matthewcheok commented 10 years ago

Here's an implementation for MCCustomView:

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
    UIView *view = [super hitTest:point withEvent:event];
    return view == self ? nil : view;
}

This essentially means that areas within the view that do not contain subviews will be regarded as not 'inside' of the view, and will pass touches to whatever is behind (like your buttons).

lemak5 commented 10 years ago

Thank you ! It Works! One more thing if it is possible : What changes should I make to MCPanelViewController class for :

Thank you for your job and your help !