0

i hava an app layout like the image: enter image description here

It has a mainViewController with a header,footer,and a view between. Other ViewControllers load in to the Other view controllers view. (so header and footer are fixed for all other ViewControllers).

Problem : In one of my View controllers i call UIImagePickerController like this :

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.mediaTypes =[UIImagePickerController availableMediaTypesForSourceType:picker.sourceType];
// picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:picker animated:YES completion:NULL];

and after returning i use default delegate :

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {


if([info[UIImagePickerControllerMediaType] isEqualToString:@"public.image"])
{
    {
        //some code
    }
}
else if([info[UIImagePickerControllerMediaType] isEqualToString:@"public.movie"])
{
  //some code
}

//   self.imageView.image = selectedImage;

[self dismissViewControllerAnimated:YES completion:nil];

}

After returning back from UIImagePickerController the inside View (Other view controllers) became full screen and it goes behind header and footer.

1) i tried resizing the view after returning back. but not working. 2) i tried adding these code :

- (void)navigationController:(UINavigationController 

*)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    [[UIApplication sharedApplication] setStatusBarStyle:YES];
}
-(BOOL)prefersStatusBarHidden   // iOS8 definitely needs this one. checked.
{
    return YES;
}

-(UIViewController *)childViewControllerForStatusBarHidden
{
    return nil;
}

none of them works,Pleaes help. Any help appreciated

----Edit----

maybe this help . i use the following code to show other view controllers in main view controllers . main_view is the view between header and footer. and the New page is the controller than i call UIpicker inside and it became fullscreen

 New_page *np = [[New_page alloc] initWithNibName:@"New_page" bundle:nil];
uicontroller=np;
[uicontroller.view setFrame:CGRectMake(0, 0, main_view.frame.size.width, main_view.frame.size.height)];
[main_view addSubview:uicontroller.view];
majid mobini
  • 107
  • 1
  • 8

1 Answers1

0

I would try by replacing

[picker dismissViewControllerAnimated:YES completion:NULL];

 [self.presentingViewController dismissViewControllerAnimated:YES completion:nil];

by a simple

 [self dismissViewControllerAnimated:YES completion:nil];

unless there is a reason to call dismiss twice i don't see?

Anyhow, the viewcontroller that present must be the one that dismiss. So same way you write

[self presentViewController:picker animated:YES completion:NULL];

you shoud write

[self dismissViewControllerAnimated:YES completion:nil];

That might as well fix it

Florian Burel
  • 3,408
  • 1
  • 19
  • 20
  • first i used UIImagePickerController in the other view controller itself and i only called [picker dismissViewControllerAnimated:YES completion:NULL]; (but no luck) then i create a temp view controller and called the picker on that one so i called [picker dismissViewControllerAnimated:YES completion:NULL]; to dissmis the picker and [self.presentingViewController dismissViewControllerAnimated:YES completion:nil]; to dis miss the temp view controller none of them worked – majid mobini Aug 12 '16 at 12:30
  • i used [self presentViewController:picker animated:YES completion:NULL]; to presend uipicker and [self dismissViewControllerAnimated:YES completion:nil]; to dismiss UIcontroller. but still it became full screen. – majid mobini Aug 12 '16 at 17:11