我是robovm的新手。我正在使用 Eclipse Juno。我刚刚更新到最新的 robovm 安装。在升级之前,ios 演示应用会短暂运行,然后崩溃。只有当代码尝试创建 UINavigationControllerDelegate 时它才会崩溃。
当我尝试创建 UINavigationControllerDelegate 时,出现此异常:
Exception in thread "main" java.lang.UnsupportedOperationException: Cannot create instances of MyNavControllerDelegate
at org.robovm.objc.ObjCObject.alloc(ObjCObject.java)
at org.robovm.objc.ObjCObject.<init>(ObjCObject.java)
at MyNavControllerDelegate.<init>(MyNavControllerDelegate.java)
at IOSDemo.didFinishLaunching(IOSDemo.java)
at org.robovm.apple.uikit.UIApplicationDelegate$ObjCProxy.$cb$application$didFinishLaunchingWithOptions$(Unknown Source)
at org.robovm.apple.uikit.UIApplication.main(Native Method)
at org.robovm.apple.uikit.UIApplication.main(UIApplication.java)
at IOSDemo.main(IOSDemo.java)
下面是 UINavigationControllerDelegate 的实现。实现还没有做任何事情。我只是想测试一下robovm运行典型代码的能力。
import org.robovm.apple.uikit.UIInterfaceOrientation;
import org.robovm.apple.uikit.UINavigationController;
import org.robovm.apple.uikit.UINavigationControllerDelegate;
import org.robovm.apple.uikit.UINavigationControllerOperation;
import org.robovm.apple.uikit.UIViewController;
import org.robovm.apple.uikit.UIViewControllerAnimatedTransitioning;
import org.robovm.apple.uikit.UIViewControllerInteractiveTransitioning;
import org.robovm.objc.annotation.Method;
import org.robovm.rt.bro.annotation.MachineSizedUInt;
public class MyNavControllerDelegate extends org.robovm.objc.ObjCObject implements UINavigationControllerDelegate {
@Override
@Method(selector = "navigationController:willShowViewController:animated:")
public void willShowViewController(UINavigationController navigationController, UIViewController viewController, boolean animated) {
}
@Override
@Method(selector = "navigationController:didShowViewController:animated:")
public
void didShowViewController(UINavigationController navigationController, UIViewController viewController, boolean animated) {
}
@Override
@Method(selector = "navigationControllerSupportedInterfaceOrientations:")
@MachineSizedUInt
public
long getSupportedInterfaceOrientations(UINavigationController navigationController) {
return 0;
}
@Override
@Method(selector = "navigationControllerPreferredInterfaceOrientationForPresentation:")
public
UIInterfaceOrientation getPreferredInterfaceOrientation(UINavigationController navigationController) {
return null;
}
@Override
@Method(selector = "navigationController:interactionControllerForAnimationController:")
public
UIViewControllerInteractiveTransitioning getInteractionController(UINavigationController navigationController, UIViewControllerAnimatedTransitioning animationController) {
return null;
}
@Override
@Method(selector = "navigationController:animationControllerForOperation:fromViewController:toViewController:")
public
UIViewControllerAnimatedTransitioning getAnimationController(UINavigationController navigationController, UINavigationControllerOperation operation, UIViewController fromVC, UIViewController toVC) {
return null;
}
}