我只是試圖顯示相機或照片庫,以便用戶可以選擇圖像並返回到應用程序。我終於可以做到了,但我面臨的問題是,當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'取代我的應用主屏幕與視圖控制器,所以,當我回來時,視圖不再存在:( –