Thursday, 8 August 2013

UIProgressView for local html in UIWebView - iOS

UIProgressView for local html in UIWebView - iOS

I have an app that loads local html files. As the html loads, I have a
UIActivityIndicator. When the html finishes loading the Activity Indicator
goes away. I would instead like to use a UIProgressView on the top of my
page, where the bar loads accurate progress then disappears when it is
finished. How could I go about doing that? here is my code for the
UIActivityIndicator.
.h
#import <UIKit/UIKit.h>
@interface MidnightPraiseViewController : UIViewController {
IBOutlet UIWebView *webview;
IBOutlet UIActivityIndicator *activityind;
NSTimer *timer;
}
@end
.m
- (void)viewDidLoad
{
[webview loadRequest:[NSURLRequest requestWithURL:[NSURL
fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"Content/Directory2/HTMLFile1"
ofType:@"html"]isDirectory:NO]]];
[super viewDidLoad];
[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.hidden = TRUE;
else
activityind.hidden =FALSE;
}

No comments:

Post a Comment