objective c - Attempt to present modal VC on VC whose view is not in the window hierarchy -


i have storyboard looks this:

storyboard

this how works: initialslidingviewcontroller instantiates navigation vc topviewcontroller follows in .m file:

 -(void)viewdidload {   [super viewdidload];    self.topviewcontroller = [self.storyboard instantiateviewcontrollerwithidentifier:@"navigation"];  } 

after navigation vc gets instantiated, creates underlying menu , sets underleftvc. using ecslidingviewcontroller. creates sliding menu uses pan gesture, similar facebook.

the rootvc navigationvc itemscdtvc. when click + button, pops action sheet allows me take photo camera or choose photo library. however, want modally segue manageitemvc , set picture chose/took uiimageview. when try present, throws following error:

warning: attempt present <manageitemviewcontroller: 0x81d52a0> on <initialslidingviewcontroller: 0x8122ce0> view not in window hierarchy! 

which true, because initialslidingvc not on screen, itemcdtvc is, how fix this?

i have set modal type segue in storyboard identifier flexible space @ bottom (when tapped, doesn't anything, chose create visual segue). segue code in itemcdtvc:

 -(void)imagepickercontroller:(uiimagepickercontroller *)picker didfinishpickingmediawithinfo:(nsdictionary *)info {     // let's edited image     uiimage *image = info[uiimagepickercontrollereditedimage];     // if reason disable editing in future, our safeguard     if(!image) image = info[uiimagepickercontrolleroriginalimage];     if(image) {         self.pictureimageview.image = image;         [self performseguewithidentifier:@"additemsegue" sender:self];     }     [self dismissviewcontrolleranimated:yes completion:nil]; }   -(void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender {     if([segue.identifier isequaltostring:@"additemsegue"]){         manageitemviewcontroller *manageitemvc = (manageitemviewcontroller *)[segue destinationviewcontroller];         manageitemvc.pictureimageview = self.pictureimageview;     } } 

it fails when trying present modal vc.

fixed, thing had dismiss imagepickercontroller before trying perform segue, so:

- (void)imagepickercontroller:(uiimagepickercontroller *)picker didfinishpickingmediawithinfo:(nsdictionary *)info {     // let's edited image     uiimage *image = info[uiimagepickercontrollereditedimage];     // if reason disable editing in future, our safeguard     if(!image) image = info[uiimagepickercontrolleroriginalimage];     if(image) {         self.pictureimage = image;         [self dismissviewcontrolleranimated:no completion:^{             [self performseguewithidentifier:@"additemsegue" sender:self];         }];     } } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -