我有一个ViewController
嵌入在测试中的测试NavigationController
.在测试中,ViewController
我有一个WebView
按钮.当我点击button
它导航到SafariViewController
它并且它正在加载给定的URL.在这WebView
当我点击"完成"按钮,它调用名为委托方法safariViewControllerDidFinish
.但这SafariViewController
并没有被驳回.
这是我的代码.
- (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]; }
完成button
是呼唤,观点不是解雇.我检查日志中self
和controller
,两者都是正确的.
你不应该说
[self showViewController:safariVC sender:nil];
你应该说
[self presentViewController:safariVC animated:YES completion:nil];
SFSafariViewControllers旨在以模态方式呈现,并在按下完成时自动解除.