IOS8. A view of a modal view deletes a subview.

I am updating our compilation application using xcode6 / iOS8.

One problem that I am facing is when presenting a modal representation. the base unit is deleted. It is completely obscured .. until the modal representation is rejected .. then it reappears.

Anyone run into this with iOS8? The same code worked with iOS4.

the code:

    PigDetailViewController *pigDetailViewController = [[PigDetailViewController alloc] initWithNibName:@"PigDetailViewController" bundle:nil];

    self.navigationController.modalPresentationStyle = UIModalPresentationCurrentContext;
    self.navigationController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;


    [self presentViewController:pigDetailViewController animated:YES completion:nil];
+4
source share
3 answers

iOS 8 , UIModalPresentationCurrentContext , UIModalPresentationOverCurrentContext. , UIModalPresentationCurrentContext, , , :

PigDetailViewController *pigDetailViewController = [[PigDetailViewController alloc] initWithNibName:@"PigDetailViewController" bundle:nil];
pigDetailViewController.modalPresentationStyle = UIModalPresentationOverCurrentContext;
self.navigationController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:pigDetailViewController animated:YES completion:nil];

, iOS 7 , , , .

edit: . iOS7 UIModalPresentationCurrentContext, VC , VC viewDidAppear. iOS8 UIModalPresentationOverCurrentContext , VC viewDidAppear, , VC, , .

+3

BrennanR.. viewWillAppear , VC, , .

0

, , .

, . ( ), .

, view.backgroundColor (), . , .

, , "", , .

, , - ...

// in the view controller that is presenting the modal VC
modalVC = // the modal VC that you will be presenting

UIView *snapshotView = [self.view snapshotViewAfterScreenUpdates:NO];
[modalVC.view insertSubView:snapshotView atIndex:0];

// present the modal VC

This will lead to a “screenshot” of the current hierarchy of views, and then place this snapshot under everything that is in modal VC.

Thus, your black screen will be replaced by a screenshot of the previous controller.

-1
source

All Articles