What is startActivityForResult analogue in RoboVM?

2019-07-30 00:34发布

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

标签: robovm
1条回答
冷血范
2楼-- · 2019-07-30 01:00

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

查看更多
登录 后发表回答