My app's code workflow goes as follows: viewDidLoad->viewDidAppear->create subview->animate subview
The animation makes the subview go from a transformation of extremely small to the size that it should be, giving it an effect similar to a UIAlert show. The code that I have works flawlessly when I run the app from my Mac, but somehow doesn't want to after I unplug the iPad and run it by itself. I tried quitting the app and trying again and even going to the lengths of restarting the iPad to get it to work, but with no avail.
Here's my code:
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
[self setUpScreen];
}
And the setUpScreen method...
// Populates the setUpView with various other items (unimportant for the issue in question)
setUpView.transform = CGAffineTransformMakeScale(0.01, 0.01);
[self.view addSubview:setUpView];
[UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionCurveEaseOut
animations:^{
setUpView.transform = CGAffineTransformIdentity;
}
completion:^(BOOL finished){
}];
So again, to reiterate my problem, the "zoom in" animation works perfectly when the app runs straight from Xcode, but fails to do so (the view just appears there) when the app is run without the assistance of Xcode.
I have tried adding a delay in the animatewithDuration: method and I have also tried adding a sleep before the setUpView method is called. I'm open to trying anything.
Also, I have the subview disappear with an animation when a button on it is pressed and that animation works fine no matter how I run the app, my only problem is at startup.
I found that my [NSThread sleepForTimeInterval:0.1] between the [super viewDidAppear:animated] and the [self setUpScreen] was not long enough (one of the solutions I had tried before posting the question). It seems as if making the time interval be 0.5 solves my problem. However, if there are any better solutions, please do share.