0

我有从相册中选择图像的按钮。选择图像后,我需要显示导航栏和分享按钮。但是选择图像后导航栏没有显示。我使用了`[self.navigationController.navigationBar setHidden:NO];。但是导航栏没有显示。

代码:

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

}
4

2 回答 2

1

之后隐藏导航栏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];
}  

或者把它放进去viewWillAppear,因为这会在dismiss你调用ModalViewController

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    [self.navigationController.navigationBar setHidden:NO];
}
于 2013-07-03T10:33:58.903 回答
0

在您展示 ImagePicker Controller 的视图中,请添加

[self.navigationController.navigationBar setHidden:NO];

ViewWillAppear方法中。我认为这可能是问题所在。请让我了解最新情况。

于 2013-07-03T10:14:35.220 回答