I'm trying to create an activity indicator in my app. I'm using a storyboard and I have created a button which is pushing another view.
Here is how I open another view:
- (IBAction)openView {
NSLog(@"View is loading");
@try {
UINavigationController *nav = [storyboard instantiateViewControllerWithIdentifier:@"viewOpenSegue"];
[nav setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentModalViewController:nav animated:YES];
}
@catch (NSException *exception) {
NSLog(@"Error");
}
@finally {
NSLog(@"View loaded");
}
}
Everythings good so far. I got the log before view gets opened, and the 2nd log after it is fully loaded.
But when I want to use addSubview method, I am having a weird behavior.
NSArray *subviewArray2 = [[NSBundle mainBundle] loadNibNamed:@"View" owner:self options:nil];
loadingView = [subviewArray2 objectAtIndex:0];
That's how I load my view. And I add/remove like this:
[self.view addSubview:loadingView];
//@try block
//@catch block
//@finally
{
[loadingView removeFromSuperview];
}
I expect the view appear and disappear on screen. But it appears for like 1 millisecond right before pushed view appears then disappear suddenly.
If I add this way under viewDidLoad, it appears.
I have seen similar questions but they didn't help me out. Anyone has a clue? Should I try something else?
Thanks in advance.