I am having a problem in an animation of a view.
Firstly, I made an animation within ViewDidLoad
method. It works perfectly.
Then within the view, I need to call out another view from the storyboard by storyboard ID using the below method
UIStoryboard *story = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
myprofile *obj = [story instantiateViewControllerWithIdentifier:@"myprofile"];
[self presentViewController:obj animated:YES completion:nil];
This view is just use for preferences and setting. After the setting is done, I called
[self dismissViewControllerAnimated:YES completion:nil];
The problem came when it dismissed. It can go back into the viewDidload
before, but the animation started again.
My question is, is there anyway I can skip the animation that I called in viewDidload
when I dismiss my second view?
Many Thanks
You can use add/post local notification for this.Manage a bool variable with YES for a go animation and NO for no animation. Add observer in the viewdidLoad before calling the animation.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(SettingsDone) name:@"AnimationDone" object:nil];
if (goAnimate){
UIStoryboard *story = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
myprofile *obj = [story instantiateViewControllerWithIdentifier:@"myprofile"];
[self presentViewController:obj animated:YES completion:nil];
}
-(void)SettingsDone{
goAnimate=NO;
}
You can post a local notification to parent class before dismissing the pop up view.
[NSNotificationCenter defaultCenter]postNotificationName:@"AnimationDone" object:nil userInfo:nil];
[self dismissViewControllerAnimated:YES completion:nil];