Re: Allow tap events outside a custom UIPresentationController on iPad(iOS 8)
Re: Allow tap events outside a custom UIPresentationController on iPad(iOS 8)
- Subject: Re: Allow tap events outside a custom UIPresentationController on iPad(iOS 8)
- From: Mike Abdullah <email@hidden>
- Date: Sat, 31 Jan 2015 23:05:13 +0000
Since iOS 8, custom presentations we write completely block events to the presenter. I assume Apple have done this because it’s the behaviour we’d mostly like. Besides, it matches Apple’s own presentations:
Alerts ignore taps outside of the alert
Action sheets treat a tap on the background area as equivalent to hitting cancel
Popovers treat taps outside the the popover as a cue to dismiss
There is an important exception here though: popovers offer the passthroughViews property, as a means to allow events through to certain specific views. How are Apple achieving this?
I have to admit I don’t actually know. But my hunch is they’re supplying a custom view as part of the presentation, that fills the container. It’s job is to override -hitTest:event: to return one of the passthrough views if appropriate. That would have the desired effect of allowing events through to those specific views.
I don’t know if that’s how it’s actually being done, or if it’s a good idea for you to do the same. Just a theory!
> On 29 Jan 2015, at 14:15, Mazzaroth M. <email@hidden> wrote:
>
> I forgot to add the overridden methods:
>
> - (CGRect)frameOfPresentedViewInContainerView
> {
> CGRect presentedViewFrame = CGRectZero;
> CGRect containerBounds = [[self containerView] bounds];
>
> presentedViewFrame.size = [self
> sizeForChildContentContainer:(UIViewController<UIContentContainer> *)[self
> presentedViewController]
>
> withParentContainerSize:containerBounds.size];
>
> presentedViewFrame.origin.x = containerBounds.size.width -
> presentedViewFrame.size.width;
> NSLog(@"presentedViewFrame: %@",
> NSStringFromCGRect(presentedViewFrame));
> return presentedViewFrame;
>
> }
>
>
> - (CGSize)sizeForChildContentContainer:(id <UIContentContainer>)container
> withParentContainerSize:(CGSize)parentSize
> {
> return CGSizeMake(floorf(parentSize.width / 3.0),
> parentSize.height);
> }
>
>
> On Wed, Jan 28, 2015 at 7:20 PM, Mazzaroth M. <email@hidden> wrote:
>
>> I want to have a custom `modal` appear over the Master portion of a
>> UISplitViewController. So far, I've managed to cobble together a
>> UIViewControllerTransitioningDelegate, a UIPresentationController subclass.
>>
>> chartSummaryNavigationController.transitioningDelegate =
>> _transitioningDelegate;
>> [self presentViewController:chartSummaryNavigationController
>> animated:YES completion:NULL];
>>
>> in the UIPresentationViewController subclass, I override
>>
>> -frameOfPresentedViewInContainerView
>> and
>> -sizeForChildContentContainer:withParentContainerSize:
>>
>> so far. Just hoping to get it `working` and in
>> -sizeForChildContentContainer:withParentContainerSize: return a smaller
>> width than the landscape iPad. Voila, the modal does a standard
>> presentation transition from the bottom of the screen. However, tapping
>> anywhere around the presented modal results in no events, which is what I
>> actually want. In -frameOfPresentedViewInContainerView I noticed that
>> self.containerView.frame returns a frame the size of the entire iPad. Is
>> that why I get no events around the presentedViewController? If so, how do
>> I reduce the frame of self.containerView to match that of the presented
>> controller?
>>
>> If that's not the problem, is there another way to allow tap events
>> outside a presented view controller?
>>
>> Michael
>>
>>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden