0
我寫了我的代碼-(void)loadView{ }
使用NSURL從互聯網上獲取圖像。但在加載圖像之前,我需要顯示微調器(UIActivityIndicatorView
)。在哪裏可以使用UIActivityIndicatorView?
#import "ImageFromWebViewController.h"
#define USE_TEST_SERVER 1
@implementation ImageFromWebViewController
+(NSString *)fileName
{
#if USE_TEST_SERVER
return @"http://happyhyderabad.files.wordpress.com/2009/04/anushka4.jpg";
#else
return @"http://nutritionresearchcenter.org/healthnews/wp-content/uploads/2008/07/johnny_depp.jpg";
#endif
}
- (void)loadView {
NSString *urlString = [ImageFromWebViewController fileName];
NSURL *url = [NSURL URLWithString:urlString];
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]];
imageView = [[UIImageView alloc] initWithImage:image];
contentView = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
[contentView setContentSize:[image size]];
[contentView addSubview:imageView];
[imageView setUserInteractionEnabled:NO];
self.view = contentView;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (void)dealloc {
[imageView release];
[contentView release];
[super dealloc];
}
@end
在viewDidLoad
我寫的代碼爲UIActivityIndicatorView
,但圖像的加載後的微調開始,並沒有停止。
我應該在哪裏編寫微調代碼?