Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 12-24-2010, 02:25 AM   #1 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 1
phipps73 is on a distinguished road
Default opening UIWebView links in Modal View fails on second click

Hi,
I am developing an tab bar based app. One of the tabs is a navigation controller containing a table view. When a cell is selected it loads the detail view which contains a UIWebView. All this works great. Some of the loaded web pages contain links to other sites and I wanted to open these in a modal view like Twitterific or Echofon etc. I set up the necessary modal view which loads a webview of the clicked link's target. This also works. The modal view has a close button which dismisses the modal view. All good so far.

The problem comes if I click another link in the detail view. Instead of loading the modal view again it simply loads the web page into the detail view replacing the original webview content.

This is my webView:shouldStartLoadWithRequest:navigationType method:

Code:
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType) navigationType 
{
	NSURL *requestURL = [ [ request URL ] retain ];
	if (![[requestURL host] isEqualToString: @"www.mywebviewcontent.org"] && navigationType == UIWebViewNavigationTypeLinkClicked) {
		NSString *url = [requestURL absoluteString];
		NSLog(@"url:%@",url);
		ModalWebViewController *controller = [[ModalWebViewController alloc] initWithNibName:@"ModalWebView" bundle:nil];
		controller.delegate = self;
		controller.detailUrl = url;
		controller.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
		[self presentModalViewController:controller animated:YES];
		
		[controller release];
		[requestURL release];
		return NO;
	} else {
	      [ requestURL release ];
              return YES;
	}
	
}
The parentViewController (detail view) also has the usual:

Code:
- (void)modalWebViewControllerDidFinish:(ModalWebViewController *)controller {
   	[self dismissModalViewControllerAnimated:YES];
}
What I don't understand is why it works perfectly when the first link is clicked but then fails to load the modal view on other links that are clicked.

The only way to fix is to click the back button on the navigation bar to go back to the table view and then come back to the detail view.

Any ideas would be really appreciated.

Cheers,

Dave
phipps73 is offline   Reply With Quote
Reply

Bookmarks

Tags
modal, uiwebview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 387
8 members and 379 guests
chemistry, daudrizek, jeroenkeij, Kirkout, PavelMik, whitey99
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,665
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, daudrizek
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:01 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0