0
我在我的應用程序中有兩個圖像選擇器。我做了第一個正確的。用戶可以從庫中選擇或捕獲照片並在視圖中查看。但是當我嘗試複製代碼並粘貼它並更改動作和對象名稱時,我在兩行中出現錯誤。在一個視圖中的兩個ImagePickerControllers
-(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];
}
兩個「(無效)」 S我得到這個錯誤:重複的方法ImagePickerControllerDidcancel和ImagePickerControllerdidFinishPickingMediaWithINfo
的聲明這將是巨大的,如果你能爲我解決的代碼。由於
感謝您的幫助,我很抱歉,如果我的英語不夠好
您必須使用,如果這些方法裏面的語句來找出哪些選擇器被稱爲('如果(拾取== self.picker1)')或類似的東西。 – mrosales
你能更具體我沒有足夠的發展知識。 –