簡體   English   中英

從弧形ViewController中呈現非弧形ViewController

[英]Presenting a non-arc ViewController from within an arc ViewController

-集成到主應用程序后的更新名稱和附加回溯-

我有一個簡單的iOS應用程序,其中包含兩個控制器:

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

我試圖使用下面的代碼通過觸摸UIButton來調用TestViewController中的BXDemoViewController:

-(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

使用以下方法將非Arc ViewController轉換為Arc Controller

在目標->編譯器源->雙擊添加的非ARC Viewcontroller的.m文件,並將該標志命名為-fno-objc-arc。 現在它將正常工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM