EDIT Problem reinstated from scratch.
I have a ViewController
A which has a Navigation Bar Button which presents an UIImagePickerController
of sourcetype UIImagePickerControllerSourceTypeCamera
, we'll call this ViewController B. In the didFinishPickingMediaWithInfo:
method of A, I then present ViewController C.
The problem now starts here. When I finally reach C, we can see that view stack is clearly:
A -modal-> B -modal-> C
From C I then have a "Back" button present on the navigation bar which should take me back to B. However, since B is an UIImagePickerController, I cannot reuse it and it must be dismissed. So, to make this happen, I currently have the following method executing for that "Back" button on C:
- (IBAction)backOnPost:(UIBarButtonItem *)sender
{
[self.view endEditing:YES];
UINavigationController *LogControl = [self.storyboard instantiateViewControllerWithIdentifier:@"LogControl"];
RGLogViewController *logView = (RGLogViewController *)LogControl.topViewController;
[UIView animateWithDuration:0.25 animations:^{
self.presentingViewController.view.alpha = 0;
[self.presentingViewController dismissViewControllerAnimated:NO completion:nil];
[self.presentingViewController.presentingViewController dismissViewControllerAnimated:NO completion:nil];
} completion:^(BOOL finished){
[logView setBoolBackPushed];
}];
}
The above code works in that it takes me back to A by dismissing B and C. However, you can still see the transition because of a bit of "black-screening" from the dismissal of the two ViewControllers. You can see in the completion block [logView setBoolBackPushed];
, this sets a static BOOL variable to true so that the beginning of A's viewWillAppear:
presents a new UIImagePickerController
immediately - the method looks like this:
- (void)viewWillAppear:(BOOL)animated
{
NSLog(@"HERES postBackButtonPushed:%hhd", postBackButtonPushed);
if(postBackButtonPushed == true)
{
self.view.hidden = YES;
self.navigationController.navigationBar.hidden = YES;
self.tabBarController.tabBar.hidden = YES;
UIImagePickerController * imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;
[self presentViewController:imagePicker animated:NO completion:^{}];
}
This is currently how I am getting the following desired effect: Go from A to the camera (B), to C and then back to a new camera which is our new B. This is achieved w/ almost perfect seamless transitions.
Im still having problems with being able to slightly see the transitions. Another problem is the timing. This collaboration of dismissing and presenting ViewControllers takes more time than I would like it to. It's almost instantaneous, but I would like something better. What should I do and am I doing something wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…