gpt4 book ai didi

iPhone 应用程序在设备上崩溃,但在模拟器上则不然。使用 UIWebView 访问本地文件,可能的 [NSBundle mainBundle] 问题?

转载 作者:行者123 更新时间:2023-12-03 19:14:15 25 4
gpt4 key购买 nike

我希望你们能帮助我,我的代码出了什么问题,导致我的应用程序在我的设备上崩溃,而不是在模拟器上崩溃。这是一个非常简单的应用程序,我只是在 UIWebView 中显示本地文件。这是我在 .m 中使用的内容

NSString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"localHTML/mobile"];
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];

我只是发布此代码,因为我觉得这里的某些内容导致了问题,但我知道什么,如果您需要查看其他内容,请告诉我。

这是崩溃日志。其中一些可能没有帮助,但我想我会发布整个内容,因为我不知道要寻找什么。

    Incident Identifier: 9598C96E-EA38-4C54-B39F-BBD245648E48
CrashReporter Key: cb7605a41daea519012d6fd4f52c4b19fb584743
Hardware Model: iPhone3,1
Process: Cannon Mobile [5129]
Path: /var/mobile/Applications/E5760D01-689A-41A3-A6CA-45E007B7C27A/Cannon Mobile.app/Cannon Mobile
Identifier: Cannon Mobile
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]

Date/Time: 2011-09-30 19:26:57.951 -0400
OS Version: iPhone OS 4.3.3 (8J2)
Report Version: 104

Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread: 0

Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x3558fa1c __pthread_kill + 8
1 libsystem_c.dylib 0x356663b4 pthread_kill + 52
2 libsystem_c.dylib 0x3565ebf8 abort + 72
3 libstdc++.6.dylib 0x35628a64 __gnu_cxx::__verbose_terminate_handler() + 376
4 libobjc.A.dylib 0x3449d06c _objc_terminate + 104
5 libstdc++.6.dylib 0x35626e36 __cxxabiv1::__terminate(void (*)()) + 46
6 libstdc++.6.dylib 0x35626e8a std::terminate() + 10
7 libstdc++.6.dylib 0x35626f5a __cxa_throw + 78
8 libobjc.A.dylib 0x3449bc84 objc_exception_throw + 64
9 CoreFoundation 0x3098048a +[NSException raise:format:arguments:] + 62
10 CoreFoundation 0x309804c4 +[NSException raise:format:] + 28
11 Foundation 0x341dd188 -[NSURL(NSURL) initFileURLWithPath:] + 64
12 Foundation 0x341dd128 +[NSURL(NSURL) fileURLWithPath:] + 24
13 Cannon Mobile 0x000033da -[Cannon_MobileViewController refresh:] (Cannon_MobileViewController.m:48)
14 Cannon Mobile 0x000034ec -[Cannon_MobileViewController viewDidLoad] (Cannon_MobileViewController.m:62)
15 UIKit 0x30a18f08 -[UIViewController view] + 104
16 UIKit 0x30a172ae -[UIWindow addRootViewControllerViewIfPossible] + 26
17 UIKit 0x30b42538 -[UIWindow setRootViewController:] + 160
18 Cannon Mobile 0x00002fb6 -[Cannon_MobileAppDelegate application:didFinishLaunchingWithOptions:] (Cannon_MobileAppDelegate.m:22)
19 UIKit 0x30a1781a -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 766
20 UIKit 0x30a11b5e -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 266
21 UIKit 0x309e67d0 -[UIApplication handleEvent:withNewEvent:] + 1108
22 UIKit 0x309e620e -[UIApplication sendEvent:] + 38
23 UIKit 0x309e5c4c _UIApplicationHandleEvent + 5084
24 GraphicsServices 0x30269e70 PurpleEventCallback + 660
25 CoreFoundation 0x30957a90 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 20
26 CoreFoundation 0x30959838 __CFRunLoopDoSource1 + 160
27 CoreFoundation 0x3095a606 __CFRunLoopRun + 514
28 CoreFoundation 0x308eaebc CFRunLoopRunSpecific + 224
29 CoreFoundation 0x308eadc4 CFRunLoopRunInMode + 52
30 UIKit 0x30a10d42 -[UIApplication _run] + 366
31 UIKit 0x30a0e800 UIApplicationMain + 664
32 Cannon Mobile 0x00002f20 main (main.m:14)
33 Cannon Mobile 0x00002ec8 start + 32

Thread 1:
0 libsystem_kernel.dylib 0x355903ec __workq_kernreturn + 8
1 libsystem_c.dylib 0x356676d8 _pthread_wqthread + 592
2 libsystem_c.dylib 0x35667bbc start_wqthread + 0

Thread 2 name: Dispatch queue: com.apple.libdispatch-manager
Thread 2:
0 libsystem_kernel.dylib 0x35590fbc kevent + 24
1 libdispatch.dylib 0x35261032 _dispatch_mgr_invoke + 706
2 libdispatch.dylib 0x3526203a _dispatch_queue_invoke + 86
3 libdispatch.dylib 0x352615ea _dispatch_worker_thread2 + 186
4 libsystem_c.dylib 0x3566758a _pthread_wqthread + 258
5 libsystem_c.dylib 0x35667bbc start_wqthread + 0

Thread 3 name: WebThread
Thread 3:
0 libsystem_kernel.dylib 0x3558dc5c semaphore_wait_signal_trap + 8
1 libsystem_kernel.dylib 0x3558df52 semaphore_wait_signal + 2
2 libsystem_c.dylib 0x35664734 pthread_mutex_lock + 256
3 WebCore 0x35f533ee _ZL17_WebTryThreadLockb + 150
4 WebCore 0x35f5332e _ZL14WebRunLoopLockP19__CFRunLoopObservermPv + 14
5 CoreFoundation 0x30957a2e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 10
6 CoreFoundation 0x3095945e __CFRunLoopDoObservers + 406
7 CoreFoundation 0x3095a760 __CFRunLoopRun + 860
8 CoreFoundation 0x308eaebc CFRunLoopRunSpecific + 224
9 CoreFoundation 0x308eadc4 CFRunLoopRunInMode + 52
10 WebCore 0x35f5327e _ZL12RunWebThreadPv + 382
11 libsystem_c.dylib 0x3566630a _pthread_start + 242
12 libsystem_c.dylib 0x35667bb4 thread_start + 0

Thread 0 crashed with ARM Thread State:
r0: 0x00000000 r1: 0x00000000 r2: 0x00000001 r3: 0x00000000
r4: 0x3f86348c r5: 0x00000006 r6: 0x1d59051c r7: 0x2fe10f90
r8: 0x3ed19bf8 r9: 0x00000065 r10: 0x3180e2f0 r11: 0x3ed0c964
ip: 0x00000148 sp: 0x2fe10f84 lr: 0x3619b3bb pc: 0x360c4a1c
cpsr: 0x00000010

非常感谢您的帮助。

最佳答案

检查 Xcode 生成的应用程序包。它包含 localHTML/mobile 目录和您期望的所有文件吗?

(右键单击 Xcode 导航器面板中“产品”部分下的 appname.app,选择“在 Finder 中显示”,然后右键单击 Finder 中的应用程序包并选择“显示包内容”)

关于iPhone 应用程序在设备上崩溃,但在模拟器上则不然。使用 UIWebView 访问本地文件,可能的 [NSBundle mainBundle] 问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7617173/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com