when i transplant a 3rd party sdk from java to ios via libgdx, an error happend at handleOpenURL function.
2014-10-09 16:57:20.238 IOSLauncher[8817:510011] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[WeiboSDK handleOpenURL:url:]: unrecognized selector sent to class 0x128b360'
*** First throw call stack:
(
0 CoreFoundation 0x05af9df6 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x05108a97 objc_exception_throw + 44
2 CoreFoundation 0x05b01915 +[NSObject(NSObject) doesNotRecognizeSelector:] + 277
3 CoreFoundation 0x05a4a9c7 ___forwarding___ + 1047
4 C
my code is here
这是java绑定的地方到ios的接口
public interface WeiboSDKDelegate extends NSObjectProtocol
{
//- (void)didReceiveWeiboRequest:(WBBaseRequest *)request;
@Method(selector = "didReceiveWeiboRequest:")
public void didReceiveWeiboRequest(WBBaseRequest request);
@Method(selector = "didReceiveWeiboResponse:")
public void didReceiveWeiboResponse(WBBaseResponse response);
}
这是java和ios静态库类的绑定 @NativeClass
public class WeiboSDK extends NSObject{
static {
ObjCRuntime.bind(WeiboSDK.class);
}
@Method(selector = "getSDKVersion")
public static native NSString getVersion();
@Method(selector = "registerApp:")
public static native boolean registerApp(NSString appKey);
@Method(selector = "enableDebugMode:")
public static native boolean enableDebugMode(boolean is_on);
@Method(selector = "sendRequest:")
public static native boolean sendRequest(WBBaseRequest request);
// + (BOOL)handleOpenURL:(NSURL *)url delegate:(id)delegate;
@Method(selector = "handleOpenURL:url:")
public static native boolean handleOpenURL(NSURL url, WeiboSDKDelegate delegate);
}
java调用的地方在application里(这里已经实现了WeiboSDKDelegate接口) public boolean openURL(UIApplication application, NSURL url, String sourceApplication, NSObject annotation)
{
boolean t = false;
//public boolean openURL(UIApplication application, NSURL url, String sourceApplication, NSObject annotation)
try{
t = WeiboSDK.handleOpenURL(url, this);
}
catch(Exception e)
{
e.printStackTrace();
}
System.out.println("open url...");
return t;
}
0 comments:
Post a Comment