【发布时间】:2011-02-11 14:07:49
【问题描述】:
问候,
我目前在我的 mainViewController 上管理“加载”屏幕时遇到问题(用户访问的第一个视图。)所以基本上第一个视图会下载图像并将其放在 UIImageView 上。发生这种情况时,MBProgressHUD 会显示。现在,用户使用自己的控制器进入 secondView。用户上传图像并返回。当用户返回主视图时,主视图会重新加载,因此不会显示与以前相同的图像。所以从逻辑上讲,“正在加载”MBProgressHUD 也应该显示。尽管如此,它甚至在它显示之前就崩溃了,它在进行转换时崩溃了。
问题是错误 exc_bad_access 只有在我实现了 MBProgressHUD 时才会出现(肯定是内存管理有问题,但我似乎不明白......)这些是有问题的代码段:
mainViewController.m
- (void)viewDidLoad {
HUD = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:HUD];
HUD.delegate = self;
HUD.labelText = @"Please Wait";
[HUD showWhileExecuting:@selector(loadingOfImageAndInformation) onTarget:self withObject:nil animated:YES];
[super viewDidLoad];
}
- (void) loadingOfImageAndInformation {
// [...] get URL and blabla.
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:imageURL];
[request setDelegate:self];
[request setDidFinishSelector:@selector(requestLoadDone:)];
[request setDidFailSelector:@selector(requestLoadWentWrong:)];
[request setDownloadProgressDelegate:HUD];
[request startAsynchronous];
}
- (void)hudWasHidden {
// Remove HUD from screen when the HUD was hidded
[HUD removeFromSuperview];
[HUD release];
// HUD = nil; I tried this because I found it on another
// answer in S.O. but it didn't quite work.
// I don't think it is the same case.
// I also tried putting this on the dealloc method and
// the didReceiveMemoryWarning to no avail...
}
这是另一个question,它处理了类似的问题,但并没有真正解决我的问题。
非常感谢您以后的帮助!!
【问题讨论】:
-
如果您需要构建堆栈,请告诉我。
标签: iphone objective-c asihttprequest