Hallo,
ich würde gerne einen ImagePickerController aus meinem ViewController heraus anzeigen.
Alles anzeigen
Leider bekomme ich dann in der Konsole die folgenden Ausgaben:
Weißt da jemand rat zur Lösung?
Danke
ich würde gerne einen ImagePickerController aus meinem ViewController heraus anzeigen.
Quellcode
- @interface ViewController () <UINavigationControllerDelegate, UIImagePickerControllerDelegate> {
- UIImagePickerController *imagePickerController;
- UIButton *showPickerBtn;
- }
- @end
- @implementation ViewController
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- imagePickerController = [[UIImagePickerController alloc] init];
- imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
- imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
- imagePickerController.delegate = self;
- imagePickerController.showsCameraControls = YES;
- showPickerBtn = [[UIButton alloc] initWithFrame:CGRectMake(20, 20, self.view.frame.size.width - 40, 50)];
- [showPickerBtn addTarget:self action:@selector(showPicker) forControlEvents:UIControlEventAllTouchEvents];
- [showPickerBtn setTintColor:[UIColor blueColor]];
- [showPickerBtn setTitle:@"Show" forState:UIControlStateNormal];
- [self.view addSubview:showPickerBtn];
- [self.view setBackgroundColor:[UIColor blueColor]];
- }
- - (void)showPicker
- {
- [self presentViewController:imagePickerController animated:YES completion:nil];
- }
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- @end
Leider bekomme ich dann in der Konsole die folgenden Ausgaben:
Quellcode
- 2013-07-31 20:52:27.792 CaptureText[1478:60b] Warning: Attempt to dismiss from view controller <ViewController: 0x17e5e2d0> while a presentation or dismiss is in progress!
- 2013-07-31 20:52:27.802 CaptureText[1478:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller <ViewController: 0x17e5e2d0>.'
- *** First throw call stack:
- (0x2ebae10b 0x38d0c6c7 0x312eb3f7 0xcd897 0x312ea3db 0x312ea377 0x312ea34b 0x31426733 0x3142628d 0x312296dd 0x31228efd 0x31217ac9 0x313bc20f 0x312945af 0x31294355 0x313b599b 0x2eb76557 0x2eb75a1f 0x2eb741ff 0x2eaea6e9 0x2eaea4cb 0x3370c35b 0x3125e355 0xcee85 0x39221ab7)
- libc++abi.dylib: terminating with uncaught exception of type NSException
Weißt da jemand rat zur Lösung?
Danke
Man kann alles schaffen. Man muss es nur wollen
www.regetskcob.github.io
www.regetskcob.github.io