我想制作一款游戏,用户可以触摸电视画面,然后从照片库中选择一张照片。
我成功地使用UITextFields,将它们添加到我的EAGLView作为子视图但是我无法用UIImagePickerController做同样的事情,这似乎是我想做的唯一方法。
感谢任何帮助!
更新
根据zpasternack的建议,我设法通过添加UIImagePickerControllerDelegate,UINavigationControllerDelegate并使用此方法来显示菜单:
- (void) chooseImageFromLibrary {
if( ![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary] ) return;
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePickerController.allowsEditing = YES;
[self addSubview:imagePickerController.view];
[imagePickerController viewWillAppear:YES];
[imagePickerController viewDidAppear:YES];
}
我在开始时调用chooseImageFromLibrary方法。它显示界面,但只要我点击取消或选择应用停止。
有人可以建议我:
1)如何取消和选择按钮工作。 2)如何随时调用UIImagePickerController(通过再次调用chooseImageFromLibrary ??)。 3)当用户点击选择..我在哪里找到用户刚刚选择的UIImage?,我该如何选择它?
感谢。
答案 0 :(得分:1)
我从未在EAGLView上使用过,但通常使用presentModalViewController调用UIImagePickerControllers,如:
- (void) chooseImageFromLibrary {
if( ![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary] ) return;
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePickerController.allowsEditing = YES;
[self presentModalViewController:imagePickerController animated:YES];
}
答案 1 :(得分:0)