Giter Site home page Giter Site logo

真机会闪退? about dsbridge-ios HOT 9 CLOSED

wendux avatar wendux commented on June 3, 2024
真机会闪退?

from dsbridge-ios.

Comments (9)

wendux avatar wendux commented on June 3, 2024

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

from dsbridge-ios.

seanLee avatar seanLee commented on June 3, 2024

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

from dsbridge-ios.

seanLee avatar seanLee commented on June 3, 2024

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

from dsbridge-ios.

wendux avatar wendux commented on June 3, 2024

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

from dsbridge-ios.

seanLee avatar seanLee commented on June 3, 2024

@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需要传入的就是字符串类型.搞不懂的就是模拟器为什么是正常的.但是在真机里报错的就是这个地方

from dsbridge-ios.

wendux avatar wendux commented on June 3, 2024

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

from dsbridge-ios.

seanLee avatar seanLee commented on June 3, 2024
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);

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

from dsbridge-ios.

wendux avatar wendux commented on June 3, 2024

此问题已修复

from dsbridge-ios.

seanLee avatar seanLee commented on June 3, 2024

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

from dsbridge-ios.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.