In UIWebView 1 click a hyperlink then open UIWebView 2, click a hyperlink in UIWebView 2 then open UIWebView 3, click a hyperlink in UIWebView 3 then open UIWebView 4….
How to implement this?
I now open a second UIWebView in
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
self.otherWebView = [[UIWebView alloc] init];
numberOfOpenedWebPage ++;
self.otherWebView.tag = numberOfOpenedWebPage;
self.otherWebView.delegate = self;
CGRect frame = self.view.frame;
self.otherWebView.frame = CGRectMake(frame.size.width, 0.0f, frame.size.width, frame.size.height);
[self.view addSubview:self.otherWebView];
[otherWebView loadRequest:request];
Because every new webview need to share the delegate method, so I defined uiwebview var as class var. But I donno how to create more in shouldStartLoadWithRequest
Thanks
The problem with your current code is that you don’t check where the hyperlink is opened from.
You should rewrite the code according to this pseudocode:
Note that the UIWebViews are held by strong reference from the NSMutableArray. I am not sure how your program works, but you have to take note of this to release the UIWebView if you don’t use it anymore.