我已经构建了一个附带活动指示器的新视图,加载此笔尖,似乎在另一个视图上正常工作:
- (void)viewDidLoad {
[super viewDidLoad];
ProgressViewController *progresssView = [[ProgressViewController alloc] initWithNibName:@"ProgressViewController" bundle:nil];
[self.view addSubview:progresssView.view];
}
问题是我在加载数据时尝试删除视图:
- (void)parserDidEndDocument:(NSXMLParser *)parser {
ProgressViewController *progresssView = [[ProgressViewController alloc] initWithNibName:@"ProgressViewController" bundle:nil];
[progresssView.view removeFromSuperview];
NSLog(@"All done");
[dataTable reloadData];
}
欢迎任何帮助......
答案 0 :(得分:2)
您不能这样做,因为您的新进度指示器与添加的进度指示器不同。
你可以这样做(如果同一个类中的两个方法都是)为它声明一个实例变量和一个属性。
@interface MyViewController {
@private
ProgressViewController *progresssView;
}
@property (nonatomic, retain) ProgressViewController *progresssView;
@end
@implementation MyViewController
@synthesize progressView;
- (void)viewDidLoad {
[super viewDidLoad];
self.progresssView = [[ProgressViewController alloc] initWithNibName:@"ProgressViewController" bundle:nil] autorelease];
[self.view addSubview:progresssView.view];
}
- (void)parserDidEndDocument:(NSXMLParser *)parser {
[self.progresssView.view removeFromSuperview];
[dataTable reloadData];
}
- (void)dealloc {
[progressView release];
}
@end