我的应用程序中有两个图像选择器。我已经正确地完成了第一个。用户可以从库中选择或拍摄照片并在视图中查看。但是当我尝试复制代码并将其粘贴并更改操作和对象名称时,我在两行出现错误。
-(IBAction)TakePhoto {
picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
[picker setSourceType:UIImagePickerControllerSourceTypeCamera];
[self presentViewController:picker animated:YES completion:NULL];
}
-(IBAction)ChooseExisting
{
picker2 = [[UIImagePickerController alloc] init];
picker2.delegate = self;
[picker2 setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[self presentViewController:picker2 animated:YES completion:NULL];
}
-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
image = [info objectForKey:UIImagePickerControllerOriginalImage];
[imageView setImage:image];
[self dismissViewControllerAnimated:YES completion:NULL];
}
-(void) imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[self dismissViewControllerAnimated:YES completion:NULL];
}
//the following part is the renamed part
-(IBAction)TakePhoto2 {
picker3 = [[UIImagePickerController alloc] init];
picker3.delegate = self;
[picker3 setSourceType:UIImagePickerControllerSourceTypeCamera];
[self presentViewController:picker3 animated:YES completion:NULL];
}
-(IBAction)ChooseExisting2
{
picker4 = [[UIImagePickerController alloc] init];
picker4.delegate = self;
[picker4 setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[self presentViewController:picker4 animated:YES completion:NULL];
}
ERROR HERE !!-(void) imagePickerController:(UIImagePickerController *)picker3 didFinishPickingMediaWithInfo:(NSDictionary *)info
{
image2 = [info objectForKey:UIImagePickerControllerOriginalImage];
[imageView2 setImage:image2];
[self dismissViewControllerAnimated:YES completion:NULL];
}
ERROR HERE !!!-(void) imagePickerControllerDidCancel:(UIImagePickerController *)picker3 {
[self dismissViewControllerAnimated:YES completion:NULL];
}
对于两个“(void)”si得到这个错误:方法ImagePickerControllerDidcancel和ImagePickerControllerdidFinishPickingMediaWithINfo的重复声明
如果您能为我修复代码,那就太好了。谢谢
谢谢你的帮助,如果我的英语不够好,我很抱歉