UIImagePickerControllerSourceTypePhotoLibrary 的“CameraTakePictureOverlay”没有可见的@interface
Posted
技术标签:
【中文标题】UIImagePickerControllerSourceTypePhotoLibrary 的“CameraTakePictureOverlay”没有可见的@interface【英文标题】:No visible @interface for 'CameraTakePictureOverlay' for UIImagePickerControllerSourceTypePhotoLibrary 【发布时间】: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:'
【问题讨论】:
【参考方案1】:你从哪个超类继承CameraTakePictureOverlay
?
超级类应该是UIViewController
。 UIImagePickerController文档
展示用户界面。在 iPhone 或 iPod touch 上,通过调用当前活动视图控制器的 presentViewController:animated:completion: 方法以模态方式(全屏)执行此操作,将您配置的图像选择器控制器作为新的视图控制器传递。
【讨论】:
超类是 UIView 好的,这就是问题所在。UIView
没有 presentViewController
方法。
尝试将takeLib
代码移动到您的视图控制器,一切都会正常。以上是关于UIImagePickerControllerSourceTypePhotoLibrary 的“CameraTakePictureOverlay”没有可见的@interface的主要内容,如果未能解决你的问题,请参考以下文章