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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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 03-21-2010, 05:53 PM   #1 (permalink)
Registered Member
 
SPAS's Avatar
 
Join Date: Jan 2010
Posts: 132
Default Webview/networkActivityIndicatorVisible

I have a webview. The activity indicator animates beside the date in the status bar when I have internet access. When I don't have internet access, an alert comes up, I click dismiss but the activity indicator keeps on going. How do I make it go away? Here is my .h and .m file. Thank you kindly.



Code:
#import <UIKit/UIKit.h>

@interface WebsiteButton : UIViewController {


	IBOutlet UIWebView *myWebView; 
}

@property (nonatomic, retain) UIWebView *myWebView;

@end
.m

#import "WebsiteButton.h"


@implementation WebsiteButton

@synthesize myWebView;

-(void)viewDidLoad {
[super viewDidLoad];

[myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://website.com"]]];

self.myWebView.scalesPageToFit = YES;
self.myWebView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);

}

- (void)webViewDidStartLoad: (UIWebView *)webView
{
// starting the load, show the activity indicator in the status bar
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
}

- (void)webViewDidFinishLoad: (UIWebView *)webView
{
// finished loading, hide the activity indicator in the status bar
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;

}

-(void)webView: (UIWebView *)webView didFailLoadWithError: (NSError *)error {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Connection Error" message:@"You need an internet connection to access this page" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
[alert show];
[alert release];
}

-(void)dealloc
{
[myWebView release];
[super dealloc];
}

@end

I thought the code looked good. I've tried it on my device and the activity indicator does not keep on going when there is no internet connection (airplane mode though). Does that mean I should ignore the iPhone simulator perpetual animation and go by what the device shows?

Last edited by SPAS; 03-21-2010 at 06:36 PM.
SPAS 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: 260
22 members and 238 guests
ADY, bookesp, chillyh, ckgni, dacapo, Dani77, DarkAn, Davey555, Desert Diva, glenn_sayers, HemiMG, jakerocheleau, JasonR, LEARN2MAKE, nobre84, prchn4christ, Rudy, ryantcb, Speed, themathminister, theone8one
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,765
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

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