Reputation: 2669
I call my rss parser from MBProgressHUD and at the moment it's in viewdidappear and it works, however I want it in viewdidload so when I go back it doesn't reload it - however when I move it in to viewdidload it runs the process but not the MBProgressHUD.
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"Results";
HUD = [[MBProgressHUD alloc] initWithWindow:[UIApplication sharedApplication].keyWindow];
[self.view.window addSubview:HUD];
HUD.delegate = self;
HUD.labelText = @"Loading";
HUD.detailsLabelText = @"updating data";
//Show the HUD while the provided method executes in a new thread
[HUD showWhileExecuting:@selector(loadResults) onTarget:self withObject:nil animated:YES];
}
Any ideas?
Thanks, Tom
Upvotes: 1
Views: 1407
Reputation: 143
In viewDidLoad method, the self.view will be loaded without its superview and window. For Example, self.view.superview will be loaded in viewWillAppear method, then self.view.window will be loaded in viewDidAppear method. That's why the [self.view.window addSubview:HUD] won't be happened in viewDidLoad, but the [self.view addSubview:HUD] works.
Upvotes: 2
Reputation: 5183
Try below code, its working fine at my end.
- (void)viewDidLoad {
[super viewDidLoad];
HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
HUD.labelText = @"Loading";
HUD.detailsLabelText = @"updating data";
}
Upvotes: 0