1

外部リンクを含む UIWebView で loadHTMLString を呼び出すと、再度 loadHTMLString を試行するとクラッシュします。

HTML は次のように読み込まれます。

    NSURL *url = [[NSBundle mainBundle] URLForResource:@"help" withExtension:@"html"];
    NSString *text = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];

    [[self webView] loadHTMLString:text baseURL:nil];

help.html には、次のようなリンクを含めることができます。

リンクをタップすると、ページが読み込まれます。しかし、ナビゲーション バーに「ホーム」ボタンがあり、上記のコード (loadHTMLString) を再度呼び出すため、アプリがクラッシュします。

外部リンクが表示された後、UIWebView を「だまして」HTML 文字列を再度読み込む方法はありますか?

参考文献: iOS で HTML を読み込んだ後、UIWebView が戻らない

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: key cannot be nil'

#0  0x906b29c6 in __pthread_kill ()
#1  0x9ca6ff78 in pthread_kill ()
#2  0x0399957b in abort ()
#3  0x03b19f7b in abort_message ()
#4  0x03b17a25 in default_terminate() ()
#5  0x035620c1 in _objc_terminate() ()
#6  0x03b17a65 in safe_handler_caller(void (*)()) ()
#7  0x03b17acd in std::terminate() ()
#8  0x03b18bc2 in __cxa_throw ()
#9  0x03561f89 in objc_exception_throw ()
#10 0x03fd50de in -[__NSDictionaryM setObject:forKey:] ()
#11 0x03d485ce in -[WebHistoryPrivate visitedURL:withTitle:increaseVisitCount:] ()
#12 0x03d4a693 in -[WebHistory(WebInternal) _visitedURL:withTitle:method:wasFailure:increaseVisitCount:] ()
#13 0x03d394b5 in WebFrameLoaderClient::updateGlobalHistory() ()
#14 0x04db0747 in WebCore::HistoryController::replaceState(WTF::PassRefPtr<WebCore::SerializedScriptValue>, WTF::String const&, WTF::String const&) ()
#15 0x04dad610 in WebCore::History::stateObjectAdded(WTF::PassRefPtr<WebCore::SerializedScriptValue>, WTF::String const&, WTF::String const&, WebCore::History::StateObjectType, int&) ()
#16 0x0508041a in WebCore::JSHistory::replaceState(JSC::ExecState*) ()
#17 0x0507ec49 in WebCore::jsHistoryPrototypeFunctionReplaceState(JSC::ExecState*) ()
#18 0x0d892daf in 0x0d892daf ()
#19 0x08052e11 in JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) ()
#20 0x07fabfc3 in JSC::call(JSC::ExecState*, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) ()
#21 0x04f91d34 in WebCore::JSMainThreadExecState::call(JSC::ExecState*, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) ()
#22 0x05064d15 in WebCore::JSEventListener::handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event*) ()
#23 0x04ce9eac in WebCore::EventTarget::fireEventListeners(WebCore::Event*, WebCore::EventTargetData*, WTF::Vector<WebCore::RegisteredEventListener, 1ul>&) ()
#24 0x04ce9c76 in WebCore::EventTarget::fireEventListeners(WebCore::Event*) ()
#25 0x05333ce9 in WebCore::Node::handleLocalEvents(WebCore::Event*) ()
#26 0x04cd0419 in WebCore::EventDispatcher::dispatchEvent(WTF::PassRefPtr<WebCore::Event>) ()
#27 0x04cd16da in WebCore::EventDispatchMediator::dispatchEvent(WebCore::EventDispatcher*) const ()
#28 0x04ccf72e in WebCore::EventDispatcher::dispatchEvent(WebCore::Node*, WTF::PassRefPtr<WebCore::EventDispatchMediator>) ()
#29 0x05333eaa in WebCore::Node::dispatchEvent(WTF::PassRefPtr<WebCore::Event>) ()
#30 0x04bf85ad in WebCore::Document::finishedParsing() ()
#31 0x04e570ad in WebCore::HTMLTreeBuilder::finished() ()
#32 0x04dd4a9b in WebCore::HTMLDocumentParser::prepareToStopParsing() ()
#33 0x04c16a14 in WebCore::DocumentWriter::end() ()
#34 0x04c092a3 in WebCore::DocumentLoader::finishedLoading() ()
#35 0x052f6c22 in WebCore::MainResourceLoader::didFinishLoading(double) ()
#36 0x052f5c58 in WebCore::MainResourceLoader::continueAfterContentPolicy(WebCore::PolicyAction, WebCore::ResourceResponse const&) ()
#37 0x052f650e in WebCore::MainResourceLoader::didReceiveResponse(WebCore::ResourceResponse const&) ()
#38 0x052f4a58 in WebCore::MainResourceLoader::handleDataLoadNow(WebCore::Timer<WebCore::MainResourceLoader>*) ()
#39 0x052f8016 in WebCore::Timer<WebCore::MainResourceLoader>::fired() ()
#40 0x056e415c in WebCore::ThreadTimers::sharedTimerFiredInternal() ()
#41 0x056e4036 in WebCore::ThreadTimers::sharedTimerFired() ()
#42 0x05531c50 in WebCore::timerFired(__CFRunLoopTimer*, void*) ()
#43 0x03f11376 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ()
#44 0x03f10e06 in __CFRunLoopDoTimer ()
#45 0x03ef8a82 in __CFRunLoopRun ()
#46 0x03ef7f44 in CFRunLoopRunSpecific ()
#47 0x03ef7e1b in CFRunLoopRunInMode ()
#48 0x05723c50 in RunWebThread(void*) ()
#49 0x9ca6ded9 in _pthread_start ()
4

1 に答える 1