Xcode 4.3 IOS5 Activity Indicator in WebView with back forward stop reload buttons

Опубликовано: 19 Март 2026
на канале: Steven Brown
5,123
15

Xcode 4.3 tutorial showing a webview with back forward stop reload buttons and an activity indicator. The activity indicator is recommended because it shows the user when a page has finished loading or something else loading from the internet has finished.

It needs a little code but not much! Here is the code I used:

// declare a timer variable
NSTimer *timey;


// in the m view controller file
(void)viewDidLoad
{
[super viewDidLoad];
[webby loadRequest:[NSURLRequest requestWithURL:
[NSURL URLWithString:@"http://linkedin.com"]]];

timey = [NSTimer scheduledTimerWithTimeInterval:(0.5)
target:self
selector:@selector(loading)
userInfo:Nil
repeats:YES];

}
// and thanks to a commenter this :)
-(void)loading { if (!webby.loading) { [activityIndicator stopAnimating];  activityIndicator.hidden = YES; } else { [activityIndicator startAnimating]; activityIndicator.hidden = NO; }
}