RoboVM中的startActivityForResult模拟是什么? [英] What is startActivityForResult analogue in RoboVM?

查看:80
本文介绍了RoboVM中的startActivityForResult模拟是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用RoboVM开发iOS应用.任务是在新窗口中打开摄像机或任何其他视图,然后返回到上一个结果.我已经成功地尝试了UIPopoverController,但是iPhone惯用语不支持它.那么,RoboVM中startActivityForResult的模拟方式是什么?

I develop iOS app with RoboVM. The task is to open camera or any another view in new window and then return to previous with some result. I have successfully tried UIPopoverController allready, but it is not supported by iPhone idiom. So, what is analogue for startActivityForResult in RoboVM?

PS. UIPopoverController解决方案的代码

PS. Code for UIPopoverController solution

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);

推荐答案

在iPhone的Robovm上,您将希望全屏显示UIImagePickerController并显示以下内容:

On Robovm for iPhone, you will want to present the UIImagePickerController full-screen with something like:

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

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

See the documentation for UIImagePickerController where it describes the ways to present it:

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

这篇关于RoboVM中的startActivityForResult模拟是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆