What is startActivityForResult analogue in RoboVM?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-15 15:31:06

问题


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

回答1:


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

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



来源:https://stackoverflow.com/questions/19901633/what-is-startactivityforresult-analogue-in-robovm

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!