1

I am presenting a link in SFSafariViewController as follows:

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

I have added delegate SFSafariViewControllerDelegate and method:

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

However, when I tap the "Done" button, it often doesn't work. Especially with left hand, it doesn't ever work. However when I tap with right hand with a specific angle, it does work. This seems to indicate that the touch area for "Done" button is too small.

If I use swipe from left edge, then that works.

1 Answers1

4

I figured it out. I used XCode's "Debug View Hierarchy" and noticed that the left side of the entire SFSafariViewController was being overlayed by the UINavigationController's left edge swipe detection view and a second left edge swipe detection view. Maybe the SFSafariViewController comes with it's own left edge swipe detection view. The second view was overlapping the "Done" button touch area.

enter image description here

Then I read somewhere that SFSafariViewController should only be presented using presentViewController.

So I removed the delegate method and used this instead:

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

This works perfectly. Surprisingly, presenting this way, the swipe from left edge still seems to work fine. Looking through XCode's "Debug View Hierarchy", I notice only a single left edge swipe detection view:

enter image description here