我在使用新的 iOS 6 时遇到问题。以前我理解“viewDidUnload”。据我了解,这现已贬值,我在结束网络活动指标时遇到了一些问题。下面是我的代码。在此先感谢您的帮助!
#import "MapViewController.h"
@implementation MapViewController
@synthesize webview, url, activityindicator, searchbar;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
{
// Custom initialization.
}
return self;
}
- (void)viewDidLoad
{
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
webview.delegate = self;
activityindicator.hidden = TRUE;
[webview performSelectorOnMainThread:@selector(loadRequest:) withObject:requestObj waitUntilDone:NO];
[super viewDidLoad];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
activityindicator.hidden = TRUE;
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
[activityindicator stopAnimating];
NSLog(@"Web View started loading...");
}
- (void)webViewDidStartLoad:(UIWebView *)webView {
activityindicator.hidden = FALSE;
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
[activityindicator startAnimating];
NSLog(@"Web View Did finish loading");
}
- (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 {
webview = nil;
activityindicator = nil;
searchbar = nil;
[super viewDidUnload];
}
- (void)dealloc {
[url release];
[super dealloc];
}
@end