Objective c UIModalViewController隐藏在UIViewController后面

Objective c UIModalViewController隐藏在UIViewController后面,objective-c,uiviewcontroller,uiimagepickercontroller,uiactionsheet,presentmodalviewcontroller,Objective C,Uiviewcontroller,Uiimagepickercontroller,Uiactionsheet,Presentmodalviewcontroller,我使用的是滑动菜单,就像你在Facebook或Path应用程序中看到的那样 在后菜单中,我希望允许用户使用相机或照片库添加图像 我遇到的问题是主视图控制器,我滑动的那个,总是在顶部 动作表显示得很好,但是模态视图控制器被主视图控制器部分隐藏 这是我的选择器代码: - (void)viewDidLoad { [super viewDidLoad]; _UIPicker = [[UIImagePickerController alloc] init]; _UIPicker.

我使用的是滑动菜单,就像你在Facebook或Path应用程序中看到的那样

在后菜单中,我希望允许用户使用相机或照片库添加图像

我遇到的问题是主视图控制器,我滑动的那个,总是在顶部

动作表显示得很好,但是模态视图控制器被主视图控制器部分隐藏

这是我的选择器代码:

- (void)viewDidLoad
{
    [super viewDidLoad];

    _UIPicker = [[UIImagePickerController alloc] init];
    _UIPicker.delegate = self;
}

- (IBAction)profilePicButtonTapped
{  
    UIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle:@"Set Up Your Profile Picture" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Camera", @"Photo Library", nil];
    actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
    [actionSheet showInView:_rearTableView];
}

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 0)
    {
        _UIPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
        [self presentViewController:_UIPicker animated:YES completion:nil];
    }
    else if (buttonIndex == 1)
    {
        _UIPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        [self presentViewController:_UIPicker animated:YES completion:nil];
    }
    else
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Error" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
        [alert show];
    }
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    UIImage * selectedImage = [info objectForKey:UIImagePickerControllerOriginalImage];
    _profileImageView.image = selectedImage;
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    [picker dismissViewControllerAnimated:YES completion:nil];
}

解决此问题的一个快速方法是,在显示选择器时隐藏主ViewController,并在其关闭后再次显示。假设您有一个对主ViewController的引用,只需将其
view.hidden
属性设置为YES


另一种处理方法是从主ViewController而不是从后菜单显示它。

有道理,但是当我将属性设置为“是”时,我的主ViewController不会隐藏。要了解我想要完成什么,最好的例子是GroupMe应用程序以及如何设置组配置文件图像。