【问题标题】:SFSafariViewController Done button not working / touch area too smallSFSafariViewController 完成按钮不起作用/触摸区域太小
【发布时间】:2017-05-26 18:25:47
【问题描述】:

我在 SFSafariViewController 中呈现如下链接:

SFSafariViewController *sfvc = [[SFSafariViewController alloc] initWithURL:myurl];
sfvc.preferredControlTintColor=[UIColor blackColor];
sfvc.delegate = self;
[self.navigationController pushViewController:sfvc animated:YES];

我已添加委托SFSafariViewControllerDelegate 和方法:

- (void)safariViewControllerDidFinish:(SFSafariViewController *)controller{
    NSLog(@"safariViewControllerDidFinish");
    [self.navigationController popViewControllerAnimated:YES];
}

但是,当我点击“完成”按钮时,它通常不起作用。尤其是左手,它永远不会起作用。但是,当我用右手以特定角度敲击时,它确实有效。这似乎表明“完成”按钮的触摸区域太小。

如果我使用从左边缘滑动,那么就可以了。

【问题讨论】:

    标签: ios uinavigationcontroller sfsafariviewcontroller


    【解决方案1】:

    我想通了。我使用了 XCode 的“调试视图层次结构”,并注意到整个 SFSafariViewController 的左侧被 UINavigationController 的左边缘滑动检测视图和第二个左边缘滑动检测视图覆盖。也许 SFSafariViewController 带有它自己的左边缘滑动检测视图。第二个视图与“完成”按钮触摸区域重叠。

    然后我在某处读到 SFSafariViewController 只能使用 presentViewController 呈现。

    所以我删除了委托方法并改用它:

    SFSafariViewController *sfvc = [[SFSafariViewController alloc] initWithURL:myurl];
    sfvc.preferredControlTintColor=[UIColor blackColor];
    [self presentViewController:sfvc animated:YES completion:nil];
    

    这非常有效。 令人惊讶的是,以这种方式呈现,从左边缘滑动似乎仍然可以正常工作。查看 XCode 的“Debug View Hierarchy”,我注意到只有一个左边缘滑动检测视图:

    【讨论】:

      猜你喜欢
      • 2011-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多