我有一個應用程序,允許用戶選擇從他們的相機膠捲相片,並且在一個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;
}
}
@ Joey502,是的,試試吧 – beryllium 2012-04-01 19:57:56
真棒該訣竅,非常感謝你! – John 2012-04-01 19:59:16