i'm simply trying to show the camera or photo library so the user can select an image and return to the app. I could finally do it, but the problem that i'm facing, is that when the UIViewController ends (why the user selected an image or why the user pressed cancel) the app works, but events stopped working.
my UIViewController is defined like this:
@interface IOSNativeCb : UIViewController
- (void)imagePickerControllerUIImagePickerController *)picker didFinishPickingMediaWithInfoNSDictionary *)info;
@end
@implementation IOSNativeCb
- (void)imagePickerControllerUIImagePickerController *)picker didFinishPickingMediaWithInfoNSDictionary *)info {
[picker dismissModalViewControllerAnimated:YES];
[picker release];
//log all the dictionary of the selected image
for (id key in info) {
NSLog(@"key: %@, value: %@ \n", key, [info objectForKey:key]);
}
}
//if user canceled
- (void)imagePickerControllerDidCancelUIImagePickerController *)picker {
UIWindow *window = [UIApplication sharedApplication].keyWindow;
[picker dismissViewControllerAnimated:YES completion:^{[self dismissViewControllerAnimated:YES completion:nil];}];
[self removeFromParentViewController];
[window makeKeyAndVisible];
}
@end
and i'm initializing with this from openfl:
const void initAppGallery(){
UIWindow *window = [UIApplication sharedApplication].keyWindow;
IOSNativeCb *wn = [[IOSNativeCb alloc] init];
[window addSubview: wn.view];
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.delegate = wn;
[wn presentModalViewController:picker animated:YES];
[picker release];
}
tried several things in how i remove or dismiss the UIViewController to see if maybe the view still was principal and for that reason the events didn't worked anymore, but nothing so far.
any ideas of what i could try? anyone had any problem like this? is my first time coding in objetive-c + haxe, so i'm a bit lost of what functions or things could be the problem. i'm coding blind in a language i barely know.
Regards.
Some things that could help you find the error:
window.rootViewController = wn
instead of[window addSubview:wn.view]
[window makeKeyAndVisible]
should be done at the end of initAppGallery.Take also a look to this question, it might help you a bit.