1

我使用 RoboVM 开发 iOS 应用程序。任务是在新窗口中打开相机或任何其他视图,然后返回上一个结果。我已经成功地尝试了 UIPopoverController,但 iPhone 成语不支持它。那么,RoboVM 中 startActivityForResult 的类比是什么?

PS。UIPopoverController 解决方案的代码

final CGRect bounds = UIScreen.getMainScreen().getBounds();
UIViewController controller = app.getUIViewController();
UIImagePickerController imagePicker = new UIImagePickerController();
final UIPopoverController popoverController = new UIPopoverController(imagePicker);
imagePicker.setSourceType(UIImagePickerControllerSourceType.PhotoLibrary);
imagePicker.addStrongRef(popoverController);
popoverController.presentFromRectInView(new CGRect(x, y, viewWidth, viewHeight), controller.getView(), UIPopoverArrowDirection.Right, true);
popoverController.setPopoverContentSize(new CGSize(viewWidth, viewHeight), true);
4

1 回答 1

1

在 iPhone 版 Robovm 上,您需要全屏显示 UIImagePickerController,如下所示:

UIWindow keyWindow = UIApplication.getSharedApplication().getKeyWindow();
if(keyWindow != null) {
    keyWindow.getRootViewController().presentViewController(imagePicker, true, null);
}   

请参阅 UIImagePickerController 的文档,其中描述了呈现它的方式:

https://developer.apple.com/library/ios/documentation/uikit/reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html

于 2014-01-05T00:55:08.937 回答