I'm trying to create an custom alert-like view that is to display while data is loading, I've also got a cancel button on it in-case the loading takes too long. I'm creating it in a ViewController and adding it as a subview to the window (not View Controller as I want the Loading alert view to handle itself as much as possible). The view displays fine but when I click the button I get a 'message sent to deallocated instance' I've used the Zombie tool and it appears that everything that retains it is just releasing it right away (I'm using ARC).
I have noticed that if I use a global variable and assign my loading alert view to that it works, but that is not the desired effect. I want to be able to show it just like an Alertview. Here is my 'show' function, what can I do so that it retains itself(?).
- (void) show{
//this is so the user can't accidentally hit a button in the parent view while the
// alert is active
parentView.view.userInteractionEnabled = NO;
//I get the window
id appDelegate = [[UIApplication sharedApplication] delegate];
UIWindow *window = [appDelegate window];
//I set up the view and create/assign the correct placement of it as well as
//make it invisible so I can fade it in later.
self.view.alpha = 0.0;
self.view.frame = [self createFrameFor:self.view withOffset:0];
//since the view is smaller that the window I create an image that is the size
//of the window but semi-transparent
UIImage *bg = [self setupBackground];
backgroundView = [[UIImageView alloc] initWithImage:bg];
backgroundView.alpha = 0.7;
//I add the views to the window here
[window addSubview:backgroundView];
[window addSubview:self.view];
[activityIndicator startAnimating];
[self fadeIn:self.view];
}