UIWebView 有一个非常奇怪的问题:
我的 appdelegate 中有一个函数,可以打开 UIWebView 以显示我的隐私政策。该函数从两个不同的视图中被调用两次。一次是用户点击登录屏幕上的按钮,一次是用户点击视图上的按钮,该视图位于谷歌地图视图的顶部。
当从登录视图调用该函数时,一切正常,我可以,但是当从另一个视图调用该函数时,UIWebView 出现但不完全可操作(用于测试我加载 google.com):
我无法滚动并且我无法打开大部分链接,唯一响应触摸事件的元素在此图中标记:
这是我的代码:在我的 appdelegate 中,我有:
- (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;
}
要隐藏我调用的视图: - (void)hidePrivacy { [UIView animateWithDuration:0.3 animations:^{ privacyView.alpha = 0; privacyView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.1, 0.1); } 完成:^(BOOL 完成) { [privacyView removeFromSuperview]; }]; showPrivacy 函数从登录视图和地图视图中调用,如下所示:
WPAppDelegate *appDelegate = [[UIApplication sharedApplication]delegate];
[appDelegate showPrivacy:self.view];
那么为什么一切工作正常,当 web 视图出现在登录视图中时,为什么我可以操作一些元素但不是全部,当它出现在地图视图中时?