1
votes


I've got a very strange problem with a UIWebView:
I have a function in my appdelegate which opens a UIWebView to show my privacy policy. The function gets called twice from two different views. Once if the user clicks a button on the login screen and once if the user clicks a button on a view, which lies on top a google map view.
When the function is called from the login view everything works fine and I can , but when the function is called from the other view, the UIWebView appears but is not complete operable (for testing I load google.com):
I cannot scroll and I cannot open most of the links, the only elements, which respond to touch events are marked in this picture:

Screenshot

And here comes my code: In my appdelegate I have:

- (void)showPrivacy:(UIView *)view
{
    overlay = [[UIView alloc] initWithFrame:view.frame];
    overlay.backgroundColor = [UIColor blackColor];
    overlay.alpha = 0;
    [view addSubview:overlay];

    privacyView = [[WPPrivacyView alloc] initWithFrame:CGRectMake(15, 40, view.frame.size.width-30, view.frame.size.height-75)];
    privacyView.layer.shadowColor = [UIColor blackColor].CGColor;
    privacyView.layer.shadowOffset = CGSizeMake(0, 1);
    privacyView.layer.shadowOpacity = 0.75;
    privacyView.layer.shadowRadius = 20.0f;
    privacyView.userInteractionEnabled = YES;
    privacyView.scrollView.scrollEnabled = YES;
    privacyView.scrollView.bounces = NO;
    privacyView.scalesPageToFit = YES;
    [view addSubview:privacyView];

    [UIView animateWithDuration:0.1 animations:^{
        privacyView.alpha = 1;
    }];

    privacyView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.1, 0.1);

    CAKeyframeAnimation *bounceAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
    bounceAnimation.values = [NSArray arrayWithObjects:
                          [NSNumber numberWithFloat:0.1],
                          [NSNumber numberWithFloat:1.1],
                          [NSNumber numberWithFloat:0.95],
                          [NSNumber numberWithFloat:1.0], nil
                          ];

    bounceAnimation.duration = 0.3;
    bounceAnimation.removedOnCompletion = NO;
    [privacyView.layer addAnimation:bounceAnimation forKey:@"bounce"];

    privacyView.layer.transform = CATransform3DIdentity;
}

To hide the View I call: - (void)hidePrivacy { [UIView animateWithDuration:0.3 animations:^{ privacyView.alpha = 0; privacyView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.1, 0.1); } completion:^(BOOL finished) { [privacyView removeFromSuperview]; }]; } The showPrivacy function gets called from the login view and from the map view as follows:

WPAppDelegate *appDelegate = [[UIApplication sharedApplication]delegate];
[appDelegate showPrivacy:self.view];

So why is everything working fine, when the webview appears at the login view and why can I operate SOME elements but not all, when it appears at the map view?

1

1 Answers

2
votes

Because you're adding your overlay view as a subview. This means the superview is going to get involved with user interaction and some events will get 'stolen' or blocked. In particular, scrolling, which uses gesture recognizers.

You may want to change your design so that you present a modal view controller with your overlay. If you want the background to be the original view then you could grab an image of it before you present the modal.