提出FDTake时出错

时间:2014-04-27 16:37:44

标签: ios objective-c uinavigationcontroller uiimagepickercontroller

我从一个现有的TableViewController呈现FDTake(Github-Link)时遇到错误:

警告:尝试在NavigationViewController上显示UIImagePickerController:0x14454a880:0x14452f900,其视图不在窗口层次结构中!

NavigationViewController是UINavigationController的子类。它来自REMenu(https://github.com/romaonthego/REMenu)。

任何想法我怎么解决它?我已经向存储库写了一个问题,但没有人回答,所以我想也许你们知道为什么。

1 个答案:

答案 0 :(得分:0)

虽然我可以与您共享相同功能的代码,但我从未使用过该库。无论您使用FDTake,都可以随意使用它。不要忘记设置Actionsheet和U​​IImagePickerController委托。

-(IBAction)chooseProfilePicture:(id)sender
{ 
    UIActionSheet *filterActionSheet = [[UIActionSheet alloc] initWithTitle:@"Select Operation"
                                                                   delegate:self
                                                          cancelButtonTitle:@"Cancel"
                                                     destructiveButtonTitle:nil
                                                          otherButtonTitles:@"Choose from gallery", @"Take Photo", nil];

    [filterActionSheet showInView:self.view];
}

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init];
     imgPicker.delegate = self;
     imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;


    switch (buttonIndex) {
        case 0:
            [self.navigationController presentModalViewController:imgPicker animated:YES];
            break;
        case 1:
            if ([UIImagePickerController isSourceTypeAvailable:
                 UIImagePickerControllerSourceTypeCamera])
            {
                imgPicker.sourceType =
                UIImagePickerControllerSourceTypeCamera;
                imgPicker.mediaTypes = @[(NSString *) kUTTypeImage];
                imgPicker.allowsEditing = NO;
                [self presentViewController:imgPicker
                                   animated:YES completion:nil];
                //_newMedia = YES;
            }

            break;
        default:
            break;
    }
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo
{
    [picker dismissModalViewControllerAnimated:YES];
    //Do what you want with the captured/selected image

}

就这么简单。实际上并不需要使用第三方库。不是你的问题的答案,但它以某种方式相关。