我只是试图显示相机或照片库,以便用户可以选择图像并返回到应用程序。我终于可以做到了,但我面临的问题是,当UIViewController结束时(为什么用户选择了图像或为什么用户按下取消),该应用程序可以工作,但事件停止工作。主应用程序停止响应UIViewController结束后的事件
我UIViewController中这样定义:
@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
,我这个从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];
}
试过几件事情我怎么删除或解聘的UIViewController,看是否可能该观点仍然是主要的,因此这些事件不再有效,但迄今为止没有发生。
任何想法,我可以尝试?任何人有这样的问题?是我第一次在objetive-c + haxe中编写代码,所以我有些失去了什么功能或事情可能是问题。我用一种我几乎不知道的语言盲目编码。
问候。
1)'window.rootViewController = wn'取代我的应用主屏幕与视图控制器,所以,当我回来时,视图不再存在:( –