1

-- 集成到主应用程序后更新的名称和添加的回溯 --

我有一个简单的 iOS 应用程序,它由两个控制器组成:

  1. BXDemoViewController不使用 ARC
  2. 利用 ARC的TestViewController 。

我正在尝试使用以下代码从 TestViewController 中呈现 BXDemoViewController,该代码在触摸 UIButton 时被调用:

-(IBAction) invokeScanner: (id)sender {
    BXDemoViewController * scannerController = [[BXDemoViewController alloc] init];
    [self presentViewController:scannerController animates:YES completion:nil];
}

控制器被正确调用并且运行良好,但是当dismissViewControllerAnimated:被调用时,我得到一个EXEC_BAD_ACCESS。将呈现控制器 (TestViewController) 转换为非 ARC 代码可以解决这个问题,这表明它与我分配和使用 BXDemoViewController 的方式有关,但我想将 TestViewController 保留在 ARC 中。

我对 iOS 开发比较陌生,我有限的知识告诉我,我想以某种方式桥接 BXDemoViewController,因为它是在 ARC 控制源中调用的,但我不确定如何。

任何帮助将不胜感激。

回溯输出:

thread #1: tid = 0x2503, 0x32d5f5b0 libobjc.A.dylib`objc_msgSend + 16, stop reason = EXC_BAD_ACCESS (code=1, address=0x8002b192)
frame #0: 0x32d5f5b0 libobjc.A.dylib`objc_msgSend + 16
frame #1: 0x31df0b5e CoreFoundation`+[__NSArrayI __new:::] + 58
frame #2: 0x31df03b6 CoreFoundation`-[__NSPlaceholderArray initWithObjects:count:] + 270
frame #3: 0x39682fe6 UIKit`-[UIView dealloc] + 98
frame #4: 0x32d61488 libobjc.A.dylib`(anonymous namespace)::AutoreleasePoolPage::pop(void*) + 168
frame #5: 0x31de9440 CoreFoundation`_CFAutoreleasePoolPop + 16
frame #6: 0x31e79f40 CoreFoundation`__CFRunLoopRun + 1296
frame #7: 0x31decebc CoreFoundation`CFRunLoopRunSpecific + 356
frame #8: 0x31decd48 CoreFoundation`CFRunLoopRunInMode + 104
frame #9: 0x39bea2ea GraphicsServices`GSEventRunModal + 74
frame #10: 0x396a82f8 UIKit`UIApplicationMain + 1120
frame #11: 0x00002296 BXDemo`main + 90 at main.m:15

thread #3: tid = 0x2903, 0x31084648 libsystem_kernel.dylib`kevent64 + 24
frame #0: 0x31084648 libsystem_kernel.dylib`kevent64 + 24
frame #1: 0x344a54f0 libdispatch.dylib`_dispatch_mgr_invoke + 796
frame #2: 0x34497df8 libdispatch.dylib`_dispatch_mgr_thread$VARIANT$up + 36

thread #5: tid = 0x2b03, 0x31083eb4 libsystem_kernel.dylib`mach_msg_trap + 20
frame #0: 0x31083eb4 libsystem_kernel.dylib`mach_msg_trap + 20
frame #1: 0x3108404c libsystem_kernel.dylib`mach_msg + 40
frame #2: 0x31e7b044 CoreFoundation`__CFRunLoopServiceMachPort + 128
frame #3: 0x31e79da2 CoreFoundation`__CFRunLoopRun + 882
frame #4: 0x31decebc CoreFoundation`CFRunLoopRunSpecific + 356
frame #5: 0x31decd48 CoreFoundation`CFRunLoopRunInMode + 104
frame #6: 0x36148a44 WebCore`RunWebThread(void*) + 444
frame #7: 0x344df310 libsystem_c.dylib`_pthread_start + 308
frame #8: 0x344df1d8 libsystem_c.dylib`thread_start + 8

thread #6: tid = 0x2427, 0x3109408c libsystem_kernel.dylib`__psynch_cvwait + 24
frame #0: 0x3109408c libsystem_kernel.dylib`__psynch_cvwait + 24
frame #1: 0x344d7d2e libsystem_c.dylib`_pthread_cond_wait + 646
frame #2: 0x344e1f18 libsystem_c.dylib`pthread_cond_wait + 40
frame #3: 0x381f39a8 CoreMedia`FigSemaphoreWaitRelative + 260
frame #4: 0x3499035a MediaToolbox`fpa_AsyncMovieControlThread + 26
frame #5: 0x3821198a CoreMedia`figThreadMain + 194
frame #6: 0x344df310 libsystem_c.dylib`_pthread_start + 308
frame #7: 0x344df1d8 libsystem_c.dylib`thread_start + 8

thread #9: tid = 0x2e03, 0x000aa468 BXDemo`BitmapIsPixelOn(tagBITMAP const&, long, long) + 60
frame #0: 0x000aa468 BXDemo`BitmapIsPixelOn(tagBITMAP const&, long, long) + 60
frame #1: 0x000a9df2 BXDemo`PointMoveTillOffNoisy(tagPOINT&, Direction, tagBITMAP&, long, long) + 290
frame #2: 0x0007f966 BXDemo`ReaderDataMatrix::FindBarcodeBoundaries(tagBITMAP&, tagPOINT, tagPOINT, _BCDM*, signed char) + 3278
frame #3: 0x0007df6c BXDemo`ReaderDataMatrix::DMBarcodeRecognition(BarcodeReaderInfo&, tagBITMAP&) + 324
frame #4: 0x0007de08 BXDemo`ReaderDataMatrix::Recognize(BarcodeReaderInfo&, tagBITMAP&, BarcodeResultList&) + 236
frame #5: 0x000abba2 BXDemo`BarcodeReader::PerformRecognition(tagBITMAP&) + 686
frame #6: 0x000ab858 BXDemo`BarcodeReader::AnalyzeBarcode(ImageBase*, long, long*) + 112
frame #7: 0x000ab186 BXDemo`BXiOSAPI::recognize(void const*, int, int, long, long, bool, IOSResult&) + 398
frame #8: 0x000af860 BXDemo`-[BXRuntime RecognizeImage:width:height:stride:result:] + 244 at BXRuntime.mm:630
frame #9: 0x000ae2ee BXDemo`-[BXRuntime recognizeData:] + 234 at BXRuntime.mm:215
frame #10: 0x000b11cc BXDemo`-[BXThreadQueue dispatchThread:] + 296 at BXThreadQueue.mm:133
frame #11: 0x33a9067c Foundation`__NSThread__main__ + 972
frame #12: 0x344df310 libsystem_c.dylib`_pthread_start + 308
frame #13: 0x344df1d8 libsystem_c.dylib`thread_start + 8

thread #10: tid = 0x2f03, 0x344d489c libsystem_c.dylib`start_wqthread
frame #0: 0x344d489c libsystem_c.dylib`start_wqthread
4

1 回答 1

0

使用以下方法将非弧视图控制器转换为弧控制器

Targets->Compiler Sources->双击添加的非ARC Viewcontroller的.m文件,并给出标志为-fno-objc-arc。现在它会正常工作。

于 2013-01-21T06:30:08.383 回答