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 01-12-2010, 07:40 PM   #1 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 566
Noise is on a distinguished road
Default UIWebView not loading until refresh button is pressed?

Not sure what my issue is here. When the view is loaded, it displays properly, but the UIWebView doesn't load. Until I hit the refresh button.

The app uses a few different views.This view should open and load a UIWebView when the view is opened. Instead, it just opens to the view, and the webview doesn't load. As soon as the refresh button is hit, the activity indicator starts spinning, the site loads, then it disappears; leaving the loaded site ready to use.

What can I use to call the load request as soon as the view is opened?
Noise is offline   Reply With Quote
Old 01-12-2010, 07:57 PM   #2 (permalink)
simpsonaty Apps
 
simpsonaty's Avatar
 
Join Date: Dec 2009
Location: Australia
Posts: 93
simpsonaty is on a distinguished road
Default

have your loadRequest in the -(void)viewDidLoad method.

eg.

Code:
- (void)viewDidLoad {
    [super viewDidLoad];
	
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.mydomain.com"]]];

[activityIndicator.hidden = NO];
[activityIndicator startAnimating];
	
}
__________________
http://simpsonatyapps.com
... yep, that's our site.
simpsonaty is offline   Reply With Quote
Old 01-12-2010, 07:58 PM   #3 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 20
darylbowden is on a distinguished road
Default

edit: looks like simpsonaty beat me to it...

Quote:
Originally Posted by Noise View Post
Not sure what my issue is here. When the view is loaded, it displays properly, but the UIWebView doesn't load. Until I hit the refresh button.

The app uses a few different views.This view should open and load a UIWebView when the view is opened. Instead, it just opens to the view, and the webview doesn't load. As soon as the refresh button is hit, the activity indicator starts spinning, the site loads, then it disappears; leaving the loaded site ready to use.

What can I use to call the load request as soon as the view is opened?
I dunno exactly what you're trying to do, but I would use the [UIWebview loadRequest:] in the viewWillAppear or viewDidAppear function and see if that works. (you may have already done this, not certain...)
darylbowden is offline   Reply With Quote
Old 01-12-2010, 08:39 PM   #4 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 566
Noise is on a distinguished road
Default

Thanks - adding it to the viewDidLoad solved it.
Noise is offline   Reply With Quote
Old 01-13-2010, 12:29 AM   #5 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 566
Noise is on a distinguished road
Default

Ok - while it's now loading fine, the connection error isn't. At least - not for the initial load.

What can I do to get the error to show up if there's no connection on the initial page load?
Noise is offline   Reply With Quote
Old 01-13-2010, 03:12 AM   #6 (permalink)
simpsonaty Apps
 
simpsonaty's Avatar
 
Join Date: Dec 2009
Location: Australia
Posts: 93
simpsonaty is on a distinguished road
Default

are you using

Code:
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {

/// show error

}
__________________
http://simpsonatyapps.com
... yep, that's our site.
simpsonaty is offline   Reply With Quote
Old 01-13-2010, 03:24 PM   #7 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 566
Noise is on a distinguished road
Default

^Yes.

The Web Views are also declared as delegates for themselves.

The code works fine - however not for the initial load when the view is opened.
Noise is offline   Reply With Quote
Old 01-13-2010, 05:48 PM   #8 (permalink)
simpsonaty Apps
 
simpsonaty's Avatar
 
Join Date: Dec 2009
Location: Australia
Posts: 93
simpsonaty is on a distinguished road
Default

the error should show itself correctly on the initial load. Here's a snippet of some code in mSwears (my company's app)

Code:
- (void)viewDidLoad {
    [super viewDidLoad];
	
	[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.twitter.com/simpsonatyapps"]]];
	webView.delegate = self;
	webView.alpha = 0.4;
	
}

- (void)webViewDidStartLoad:(UIWebView *)webView {
	
	webActivity.hidden = FALSE;
	[webActivity startAnimating];
	webView.alpha = 0.4;

}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
	
	webActivity.hidden = TRUE;
	[webActivity stopAnimating];
	webView.alpha = 1;
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
	
	webActivity.hidden = TRUE;
	[webActivity stopAnimating];
	alertView = [[UIAlertView alloc] initWithTitle:@"Load Failed" message:@"Twitter failed to load. You are either not connected to the internet, or the server stopped responding" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
	[alertView show];
	[alertView release];
		
}
this works for me
__________________
http://simpsonatyapps.com
... yep, that's our site.
simpsonaty is offline   Reply With Quote
Reply

Bookmarks

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: 328
11 members and 317 guests
2Apps1Day, akacaj, Domele, GraffitiCircus, michelle, NetGuru, NSString, Paul Slocum, Sloshmonster, soohyun, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,650
Threads: 94,114
Posts: 402,886
Top Poster: BrianSlick (7,990)
Welcome to our newest member, soohyun
Powered by vBadvanced CMPS v3.1.0

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