Question

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];

}
Was it helpful?

Solution

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];
}

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top