什么是RoboVM中的startActivityForResult模拟?

时间:2013-11-11 08:13:13

标签: robovm

我使用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);

1 个答案:

答案 0 :(得分:1)

在Robovm for iPhone上,您需要在全屏显示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