我遇到了新的iOS 6問題。以前我瞭解「viewDidUnload」。這是我的理解,這是現在貶值,我有一些問題,結束網絡活動指標。以下是我的代碼。在此先感謝您的幫助!viewDidUnload幫助 - iPhone應用程序
#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
你介意重新格式化你的代碼,以便像我這樣的老人可以閱讀和理解它嗎? – Till
不應該在webViewDidFinishLoad中將networkActivityIndicatorVisible設置爲NO,並且在webViewDidStartLoad中將YES設置爲YES,而不是相反? – Sascha