我有从相册中挑选图片的按钮。选择图像后,我需要显示navigationBar和分享按钮。但是在选择图像后,navigationBar没有显示。我用`[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];
}
答案 0 :(得分: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];
}
答案 1 :(得分:0)
在您要呈现ImagePicker控制器的视图中,请添加
[self.navigationController.navigationBar setHidden:NO];
ViewWillAppear
方法中的。我认为这可能是个问题。请及时通知我。