0

I have button for picking image from photo album. After picking image, i need to show navigationBar and share button. But navigationBar is not showing after picking image. I used `[self.navigationController.navigationBar setHidden:NO];. But navigation bar not showing.

code:

-(void)showAlbum:(id)sender{

    imagePicker=[[UIImagePickerController alloc]init];

    imagePicker.delegate = self;

    imagePicker.allowsEditing =NO;

    imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

    [self presentModalViewController:imagePicker animated:YES];

}

-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
    //release picker
    [picker dismissModalViewControllerAnimated:YES];

 }

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

    [self.navigationController.navigationBar setHidden:NO];

   newImage = [[UIImageView alloc] initWithImage:[info objectForKey:UIImagePickerControllerOriginalImage]];

    [newImage setFrame:CGRectMake(0, 0, 320, 568)];

[self.view addSubview:newImage];

  [picker dismissModalViewControllerAnimated:YES];

}
user2474320
  • 315
  • 1
  • 5
  • 17

2 Answers2

1

Just hide navigation bar after dismissModalViewController

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

   newImage = [[UIImageView alloc] initWithImage:[info objectForKey:UIImagePickerControllerOriginalImage]];

    [newImage setFrame:CGRectMake(0, 0, 320, 568)];

[self.view addSubview:newImage];

  [picker dismissModalViewControllerAnimated:YES];
[self.navigationController.navigationBar setHidden:NO];
}  

Or put this in viewWillAppear, because this will call after dismiss your ModalViewController

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    [self.navigationController.navigationBar setHidden:NO];
}
Rajneesh071
  • 30,846
  • 15
  • 61
  • 74
0

In the View where you are presenting the ImagePicker Controller , Please add

[self.navigationController.navigationBar setHidden:NO];

in the ViewWillAppear Method. I think that may be the issue. Please update me on the latest.

IronManGill
  • 7,222
  • 2
  • 31
  • 52