【问题标题】:NavigationBar not showing after picking image from album从相册中选择图像后导航栏不显示
【发布时间】:2013-07-03 10:08:51
【问题描述】:

我有从相册中选择图像的按钮。选择图像后,我需要显示导航栏和分享按钮。但是选择图像后导航栏没有显示。我使用了`[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];

}

【问题讨论】:

    标签: iphone uinavigationcontroller uiimageview photo-gallery


    【解决方案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];
    }
    

    【讨论】:

      【解决方案2】:

      在您展示 ImagePicker 控制器的视图中,请添加

      [self.navigationController.navigationBar setHidden:NO];
      

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-11-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-04-06
        相关资源
        最近更新 更多