我是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;
}
}
答案 0 :(得分:2)
更改您的MyNavControllerDelegate
课程,使其扩展UINavigationControllerDelegateAdapter
,然后删除所有@Method
注释。