Activity Indicator not displaying based on whether the UIWebView is loading or not...

Posted by Jack W-H on Stack Overflow See other posts from Stack Overflow or by Jack W-H
Published on 2010-03-19T20:59:34Z Indexed on 2010/03/19 21:01 UTC
Read the original article Hit count: 423

Hi folks

Sorry if this is an easy one. Basically, here is my code:

MainViewController.h:

//
//  MainViewController.h
//  Site
//
//  Created by Jack Webb-Heller on 19/03/2010.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import "FlipsideViewController.h"

@interface MainViewController : UIViewController <UIWebViewDelegate, FlipsideViewControllerDelegate> {
    IBOutlet UIWebView *webView;
    IBOutlet UIActivityIndicatorView *spinner;
}

- (IBAction)showInfo;

@property(nonatomic,retain) UIWebView *webView;
@property(nonatomic,retain) UIActivityIndicatorView *spinner;

@end

MainViewController.m:

//
//  MainViewController.m
//  Site
//
//  Created by Jack Webb-Heller on 19/03/2010.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import "MainViewController.h"
#import "MainView.h"


@implementation MainViewController

@synthesize webView;
@synthesize spinner;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}



 // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
 - (void)viewDidLoad {

     NSURL *siteURL;
     NSString *siteURLString;

     siteURLString=[[NSString alloc] initWithString:@"http://www.site.com"];

     siteURL=[[NSURL alloc] initWithString:siteURLString];

     [webView loadRequest:[NSURLRequest requestWithURL:siteURL]];

     [siteURL release];
     [siteURLString release];

 [super viewDidLoad];
 }

- (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller {

    [self dismissModalViewControllerAnimated:YES];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    [spinner stopAnimating];  
    spinner.hidden=FALSE;
    NSLog(@"viewDidFinishLoad went through nicely");
}

- (void)webViewDidStartLoad:(UIWebView *)webView {     
    [spinner startAnimating];     
    spinner.hidden=FALSE;
    NSLog(@"viewDidStartLoad seems to be working");
}

- (IBAction)showInfo {    

    FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideView" bundle:nil];
    controller.delegate = self;

    controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:controller animated:YES];

    [controller release];
}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


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


@end

Unfortunately nothing is ever written to my log, and for some reason the Activity Indicator never seems to appear. What's going wrong here?

Thanks folks

Jack

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c