MonoTouch: Calling UIWebView.LoadHTMLString Once W

2019-08-11 01:56发布

问题:

When a UIWebView contains an external web site using LoadRequest, then the LoadHtmlString() is called, you get this error. Is there a way around this?

0   OilGasDictionary                    0x000908ec mono_handle_native_sigsegv + 284
1   OilGasDictionary                    0x00005c42 mono_sigsegv_signal_handler + 178
2   libsystem_c.dylib                   0x9555059b _sigtramp + 43
3   ???                                 0xffffffff 0x0 + 4294967295
4   OilGasDictionary                    0x00169eee mono_runtime_invoke + 126
5   OilGasDictionary                    0x0020c14d monotouch_exception_handler + 61
6   CoreFoundation                      0x011c112c __handleUncaughtException + 76
7   libobjc.A.dylib                     0x0359ef43 _objc_terminate + 86
8   libc++abi.dylib                     0x0437d8de _ZL19safe_handler_callerPFvvE + 13
9   libc++abi.dylib                     0x0437d946 __cxa_bad_typeid + 0
10  libc++abi.dylib                     0x0437eb3e __cxa_current_exception_type + 0
11  libobjc.A.dylib                     0x0359ee49 objc_exception_rethrow + 47
12  CoreFoundation                      0x010f7e10 CFRunLoopRunSpecific + 304
13  CoreFoundation                      0x010f7ccb CFRunLoopRunInMode + 123
14  WebCore                             0x07395220 _ZL12RunWebThreadPv + 560
15  libsystem_c.dylib                   0x954f8ed9 _pthread_start + 335
16  libsystem_c.dylib                   0x954fc6de thread_start + 34

回答1:

It's hard to be sure without seeing some sample code but since UIWebView.LoadRequest is not reentrant you should take care to ensure LoadHtmlStringis not called until the request has finished loading (they likely share some logic and potentially the same limitation).

My own sample did that (instinctively since I learned the reentrancy limitation recently) and works without any issue.