0

我有一個應用程序,允許用戶選擇從他們的相機膠捲相片,並且在一個UIImageView顯示它。但是,在他們挖掘上像他們想顯示,相機膠捲的觀點並沒有消失。所以,我想,我需要簡單地調用[sender resignFirstResponder];。但是,這並沒有辦法。我一直想多東西,做搜索周圍,但無濟於事。我很新的Objective-C的,所以任何的幫助深表感謝。這裏是我正在使用的代碼:(imgPicker是的UIImagePickerController) iOS裝置:和的UIImagePickerController ResignFirstResponder

- (IBAction)grabImage(id)sender { 
     self.imgPicker = [[UIImagePickerController alloc] init]; 
     self.imgPicker.delegate = self; 
     self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 

     if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { 
      _popover = [[UIPopoverController alloc] initWithContentViewController:imgPicker]; 
      [_popover presentPopoverFromRect:self.imageView.bounds inView:self.imageView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 
     } 

     else { 
      [self presentModalViewController:imgPicker animated:YES]; 
     } 
     [self.imgPicker resignFirstResponder]; 
    } 

,這可能是也可能不是相關的問題:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo { 
     if (imageView.image == nil) { 
      imageView.image = img; 
      [[picker parentViewController] dismissModalViewControllerAnimated:YES]; 
      return; 

     } 

     if (imageView2.image == nil) { 
      imageView2.image = img; 
      [[picker parentViewController] dismissModalViewControllerAnimated:YES]; 
      return; 
     } 
    } 

回答

1

你只需要這一行駁回模式選擇器在您的委託方法:

[picker dismissModalViewControllerAnimated:YES]; 

resignFirstResponder在這種情況下是沒用的

+1

@ Joey502,是的,試試吧 – beryllium 2012-04-01 19:57:56

+0

真棒該訣竅,非常感謝你! – John 2012-04-01 19:59:16

1

嘗試

[self dismissModalViewControllerAnimated:YES]; 
0

至於要取消只選擇器視圖和選擇器

不父視圖,你只需要使用:

[picker dismissModalViewControllerAnimated:YES]; 

和你做。