I have an rss feed which returns a json containing a title, short text and full-size text. The title and part of he short text is displayed in a TableView.
I have 3 controllers with 3 views. View 1 displays a TableView containing articles from the json( the title and short text ), each article has a "Read more" button, in the IBAction of the button, i push a viewcontroller(2) into the navigation controller, the controller has a UIWebView(second View), which loads a html string. The string contains links, when the user taps a link, i want to present a modal view controller with another WebView(3), this time using the request(keep in mind that both WebViews have separate controllers and nibs). The delegates are set properly on both of them, i tried both from code and using visual tools. In the delegate method shouldStartLoadWithRequest in the first WebView i check to see if the request parameter contains "http" or "www", because only then i want to call the second WebView. The second WebView works well the first time, the view is presented modally fine, but when i dismiss it and tap the same link or another, the shouldStartLoadWithRequest delegate method is not called, but the link loads in the same WebView(the first one).
I googled this but didn't find a similar case to mine, or a solution. I don't have that much experience with ios app development, but a colleague is pretty good, and we didn't manage to find a solution to this problem. We took the code apart and analyzed it, but we didn't find a potential source for this problem, and he has a separate project where he has the same problem, only he uses only one controller and one WebView (our controllers and nibs where created independantly). We were pretty thorough with the research and the code examination
It seems that the solution was quite easy. The first WebView, aparently looses the connection to it's delegate, so, in the second WebView controller just add
- (void)viewWillDisappear:(BOOL)animated {
[self.parentViewController viewWillAppear:YES];
}
and in the first controller of the first WebView:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
webView_.delegate = self;
}
I hope this helps someone