نافيا UIImagePickerController
-
20-09-2019 - |
سؤال
لدي البرمجية التالية:
SecondViewController *secondView = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
[imagePicker setCameraOverlayView:secondView.view];
[imagePicker setShowsCameraControls:NO];
[self presentModalViewController:imagePicker animated:YES];
سؤالي هو:كيف يمكنني رفض ModalViewController من "SecondViewController"?
المحلول
ويجب استدعاء التالية على imagePicker
من أسلوب UIImagePickerControllerDelegate
في secondView
.
وعلى سبيل المثال:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// process message
[imagePicker dismissModalViewControllerAnimated:YES];
}
نصائح أخرى
الجواب المقبول لم يعد يعمل في iOS7.أدناه هي الطريقة التي ينبغي أن تستخدم بدلا من ذلك.
مرة أخرى, هذه الطريقة يجب أن يطلق على UIImagePicker
من UIImagePickerControllerDelegate
.
-(void) imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[[picker presentingViewController] dismissViewControllerAnimated:YES completion:NULL];
}
لا تنتمي إلى StackOverflow