点击 上ShowWebsiteButton
显示MainViewController
网站WebViewController
。轻按一下CloseWebViewButton
应该WebViewController
会关闭WebViewController
并再次显示给我MainViewController
。注意:成功MainViewController
打开WebViewController
并加载网站,我只是无法返回MainViewController
.
主视图控制器.h
@interface MainViewController : UIViewController <UIWebViewDelegate>
@property (strong, nonatomic) WebViewController *webViewController;
主视图控制器.m
- (IBAction)showWebsiteButton:(id)sender {
NSString *fullURL = @"http://www.apple.com"
self.webViewController.delegate = self;
self.webViewController.websiteName = fullURL;
self.webViewController.serviceName = @"Apple";
[self.view addSubview:self.webViewController.view];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
[self dismissModalViewControllerAnimated:YES];
}
WebViewController.h
@property id <UIWebViewDelegate>delegate;
WebViewController.m
- (IBAction)closeBtnTapped:(id)sender {
[self.delegate webViewDidFinishLoad:self.webView];
}