【问题标题】:No visible @interface for 'CameraTakePictureOverlay' for UIImagePickerControllerSourceTypePhotoLibraryUIImagePickerControllerSourceTypePhotoLibrary 的“CameraTakePictureOverlay”没有可见的@interface
【发布时间】:2016-07-22 21:42:39
【问题描述】:

在使用访问 UIImagePickerControllerSourceTypePhotoLibrary 按钮覆盖时遇到问题是我得到的,问题出在选择器 (takeLib:) 中。

使用 imagePicker 的属性

@property (weak, nonatomic) UIImagePickerController *imagePicker;

- (UIButton *) createGetLibraryButton {

UIImage *imglibraryPicture = [StyleKit imageOfLibraryIcon];



CGRect bounds = [UIScreen mainScreen].bounds;

CGRect takePicRect = CGRectMake((bounds.size.width/2) - (imglibraryPicture.size.width/1),
                                bounds.size.height-imglibraryPicture.size.height/2-CAMERA_BOTTOM_BUTTON_PADDING,
                                imglibraryPicture.size.width/2,
                                imglibraryPicture.size.height/2);

UIButton *btnLibrary = [[UIButton alloc] initWithFrame:takePicRect];

//using  selector(takeLib:)
[btnLibrary setBackgroundImage:imglibraryPicture forState:UIControlStateNormal];
[btnLibrary addTarget:self action:@selector (takeLib:) forControlEvents:UIControlEventTouchUpInside];

return btnLibrary;
}

这里的选择器是问题发生的地方

-(void) takeLib:(id)sender
{
self.imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
self.imagePicker.delegate = self;
[self presentViewController:self.imagePicker animated:YES completion:^{
  }];
}

错误说明: No visible @interface for 'CameraTakePictureOverlay' declares the selector 'presentViewController:animated:completion:'

【问题讨论】:

    标签: objective-c uibutton uiimagepickercontroller overlay photolibrary


    【解决方案1】:

    你从哪个超类继承CameraTakePictureOverlay
    超级类应该是UIViewControllerUIImagePickerController文档

    展示用户界面。在 iPhone 或 iPod touch 上,通过调用当前活动视图控制器的 presentViewController:animated:completion: 方法以模态方式(全屏)执行此操作,将您配置的图像选择器控制器作为新的视图控制器传递。

    【讨论】:

    • 超类是 UIView
    • 好的,这就是问题所在。 UIView 没有 presentViewController 方法。
    • 尝试将takeLib 代码移动到您的视图控制器,一切都会正常。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-07
    • 2015-05-17
    • 2017-10-13
    • 1970-01-01
    • 1970-01-01
    • 2016-08-05
    相关资源
    最近更新 更多