UILongPressGestureRecognizer 被添加到我的 imageView 中,带有操作 handleLongPressOnPhotos。最相关的代码如下:
- (IBAction)handleLongPressOnPhotos:(UIImageView *)sender{
self.imageWillBeSaved = sender;
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Save the photo" otherButtonTitles: @"Go to the Original photo", nil];
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
[actionSheet showInView:self.view];
[actionSheet release];
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
switch (buttonIndex) {
case 0:
UIImageWriteToSavedPhotosAlbum(self.imageWillBeSaved.image, self, @selector(image: didFinishSavingWithError:contextInfo:), nil);
break;
default:
break;
}
}
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{
if (error != NULL)
{
// handle error
}
else
{
// handle ok status
}
}
当单击操作表上的“保存照片”按钮时,错误消息为:-[UILongPressGestureRecognizer image]: unrecognized selector sent to instance 0x21c2a0 代码有问题吗?提前致谢!
最佳答案
只需替换前两行..
- (IBAction)handleLongPressOnPhotos:(UIImageView *)sender{
self.imageWillBeSaved = sender;
与..
- (IBAction)handleLongPressOnPhotos:(UIGestureRecognizer *)sender{
self.imageWillBeSaved = sender.view;
这应该有效……David 很好地解释了发生这种情况的原因。
关于iphone - 使用 UIImageWriteToSavedPhotosAlbum 保存图像时无法识别的选择器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10510506/