I have a test ViewController
which is embedded in a NavigationController
. In test ViewController
I have a WebView
button. When I click on that button
it navigates to SafariViewController
and it's loading given URL. In that WebView
when I click on "Done" button it's calling delegate method called safariViewControllerDidFinish
. But that SafariViewController
is not being dismissed.
Here is my code.
- (IBAction)bannerWebviewAction:(id)sender {
NSURL *urls = [NSURL URLWithString:@"http://www.google.com"];
SFSafariViewController safariVC = [[SFSafariViewController alloc] initWithURL:urls];
[self showViewController:safariVC sender:nil];
safariVC.delegate = self;
}
#pragma SFSafariViewControllerDelegate
-(void)safariViewControllerDidFinish:(SFSafariViewController *)controller {
// Done button pressed
[controller dismissViewControllerAnimated:YES completion:nil];
}
Done button
is calling, view is not dismissing. I checked log for the self
and controller
, both are correct.
You should not say
[self showViewController:safariVC sender:nil];
You should say
[self presentViewController:safariVC animated:YES completion:nil];
SFSafariViewControllers are meant to be presented modally and will dismiss itself when done is pressed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With