Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

真机会闪退? #1

Closed
seanLee opened this issue Jan 7, 2017 · 9 comments
Closed

真机会闪退? #1

seanLee opened this issue Jan 7, 2017 · 9 comments
Labels

Comments

@seanLee
Copy link

seanLee commented Jan 7, 2017

你好,我想麻烦问一下.我这边相同的代码在模拟器里面能正常跑,但是在真机里就会出现闪退的情况.

@wendux
Copy link
Owner

wendux commented Jan 7, 2017

真机下的.a要重新编译真机用的 , 工程中自带的是模拟器的

@seanLee
Copy link
Author

seanLee commented Jan 7, 2017

我用你的Demo异步调用的时候也会闪退,但是在模拟器上不会.我是直接把文件夹拖入项目里的,没有使用.a文件.

@seanLee
Copy link
Author

seanLee commented Jan 7, 2017

貌似只有异步调用会闪退.

@wendux
Copy link
Owner

wendux commented Jan 7, 2017

具体是点击哪个按钮触发的?错误能定位吗?你真机和模拟器系统版本分别是多少?真机的机型是什么?

@wendux wendux added the question label Jan 7, 2017
@seanLee
Copy link
Author

seanLee commented Jan 8, 2017

@wendux 可以定位.不是按钮,就是所有异步操作都会闪退.我的Xcode和Iphone都是最新的系统版本.我用得WKWebView,就是项目中的DWKWebView.

- (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt
    defaultText:(nullable NSString *)defaultText initiatedByFrame:(WKFrameInfo *)frame
completionHandler:(void (^)(NSString * _Nullable result))completionHandler

报错方法就是这个.因为你异步操作里compeleter没有返回值.

NSString *method= [prompt substringFromIndex:[prefix length]];
        NSString *result =[JSBUtil call:method :defaultText JavascriptInterfaceObject:_JavascriptInterfaceObject jscontext:webView];
        completionHandler(result);

执行这一句代码之后,所有的异步操作这里的result都是一个字典,然后这个completionHandler需要传入的就是字符串类型.搞不懂的就是模拟器为什么是正常的.但是在真机里报错的就是这个地方

@wendux
Copy link
Owner

wendux commented Jan 8, 2017

现在手头没有真机,看了一下代码,可能是在获取使用performSelector执行的返回值类型为void的selector的返回值时,模拟器和真机处理不一样,模拟器会返回nil, 而真机却不是,可以将 JsApiTest.m 里面两个异步api函数的返回值都改成NSString试试,可以的话告诉我一声哦。

@seanLee
Copy link
Author

seanLee commented Jan 9, 2017

NSString *method= [prompt substringFromIndex:[prefix length]];
        NSString *result =[JSBUtil call:method :defaultText JavascriptInterfaceObject:_JavascriptInterfaceObject jscontext:webView];
        if (![result isKindOfClass:[NSString class]]) {completionHandler(@"");return;};
        completionHandler(result);

我把代码改成这个样子了,暂时不会出现闪退.但是不知道会不会有其他的影响。

@wendux
Copy link
Owner

wendux commented Jan 10, 2017

此问题已修复

@wendux wendux closed this as completed Jan 10, 2017
@seanLee
Copy link
Author

seanLee commented Jan 11, 2017

@wendux OK.麻烦啦.我也是准备来close这个issue的

vince-hz added a commit to vince-hz/DSBridge-IOS that referenced this issue Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants