Tutorial details

Activity Indicator | App Code for Sale | Preview

Activity Indicator | iOS Tutorial

How to use an activity indicator when loading webviews

Overview PAGE TOP

Reference: http://www.geekylemon.com/WEBPROTECT-xcode4activityindicat.htm

In this tutorial i will be showing you how to use an activity indicator when loading webviews

Features:

  • 1 UIWebView
  • 1 Activity Indicator

Using activity indicators when loading web views is a more visual effect as it gives the user something to look at before the web view loads and shows them that something is happening giving them patience when waiting

ViewController.h PAGE TOP

@interface ViewController :UIViewController {
IBOutlet UIWebView *webview;
IBOutlet UIActivityIndicatorView*activityind;
NSTimer *timer; 
}
@end

Title PAGE TOP

@implementation ViewController
- (void)viewDidLoad
{
    [super viewDidLoad];
    [webview loadRequest:[NSURLRequest requestWithURL:
[NSURLURLWithString:@"http://www.twitter.com/geekylemon"]]];
    [webview addSubview:activityind];
timer = [NSTimer scheduledTimerWithTimeInterval:(1.0/2.0)
target:self
selector:@selector(loading)
userInfo:nil
repeats:YES];
// Do any additional setup after loading the view, typically from a nib.
}
-(void)loading {  
if (!webview.loading)
        [activityind stopAnimating];
else
        [activityind startAnimating];
} 
@end

When in the interface builder make sure you select hides when stopped when editing the activity indicator to ensure its hidden when not in use

Reference PAGE TOP

http://www.geekylemon.com/WEBPROTECT-xcode4activityindicat.htm

0 Comments Leave a comment

Please login in order to leave a comment.

Newest first
!

Sign-in to your Chupamobile Account.

The Easiest way to Launch your next App or Game.

Join Chupamobile and get instant access to thousands of ready made App and Game Templates.

Creating an account means you’re okay with Chupamobile’s Terms of Service and Privacy Policy.