[英]Crash after unwind segue due to location manager
我有幾個viewcontrollers展開到根viewcontroller。 使用大多數視圖控制器,展開搜索效果良好,而不會導致應用程序崩潰。 僅使用CLlocationmanager的視圖控制器無法對根視圖控制器執行展開選擇。 這些行使我的代碼與眾不同:
//Init the location Manager
locationManager = [[CLLocationManager alloc] init];
[locationManager requestWhenInUseAuthorization];
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
locationManager.delegate = self;
通過注釋我的代碼的這一部分,展開工作。 特別是最后一行有所作為。 我試圖在放松之前釋放locationmanager。 有時可以。 有時候沒有。 調試控制台說:
0x10bfe1005: movq (%rdi), %r11
0x10bfe1008: movq %rsi, %r10
0x10bfe100b: andl 0x18(%r11), %r10d<---Thread 1: EXC Bad_Access(code=1, adress=0x18)
0x10bfe100f: shlq $0x4, %r10
0x10bfe1013: addq 0x10(%r11), %r10
不管什么意思。 我不知道該怎么做。
編輯
添加后
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
[locationManager stopUpdatingLocation];
[locationManager release];
}
這樣的作品。 我嘗試了5次。 然后它再次崩潰了:(真的很奇怪。不確定但錯誤消息似乎已經更改。它顯示為“ WebThread”(如下所示)。我確實有一個webview,其中也包含委托方法。我將嘗試以以下方式釋放該webview:好。
libobjc.A.dylib`objc_msgSend:
0x32f9af60: cbz r0, 0x32f9af9e ; objc_msgSend + 62
0x32f9af62: ldr.w r9, [r0]
0x32f9af66: ldrh.w r12, [r9, #12] <-----WebThread(10):EXC_bad_access(code=1, address=0x100000c)
0x32f9af6a: ldr.w r9, [r9, #8]
0x32f9af6e: and.w r12, r12, r1
0x32f9af72: add.w r9, r9, r12, lsl #3
0x32f9af76: ldr.w r12, [r9]
0x32f9af7a: teq.w r12, r1
0x32f9af7e: bne 0x32f9af86 ; objc_msgSend + 38
0x32f9af80: ldr.w r12, [r9, #4]
0x32f9af84: bx r12
0x32f9af86: cmp.w r12, #0x1
0x32f9af8a: blo 0x32f9af98 ; objc_msgSend + 56
0x32f9af8c: it eq
0x32f9af8e: ldreq.w r9, [r9, #4]
0x32f9af92: ldr r12, [r9, #8]!
0x32f9af96: b 0x32f9af7a ; objc_msgSend + 26
0x32f9af98: ldr.w r9, [r0]
0x32f9af9c: b 0x32f9b1e0 ; _objc_msgSend_uncached
0x32f9af9e: mov.w r1, #0x0
0x32f9afa2: bx lr
0x32f9afa4: nop
0x32f9afa6: nop
0x32f9afa8: nop
0x32f9afaa: nop
0x32f9afac: nop
0x32f9afae: nop
0x32f9afb0: nop
0x32f9afb2: nop
0x32f9afb4: nop
0x32f9afb6: nop
0x32f9afb8: nop
0x32f9afba: nop
0x32f9afbc: nop
0x32f9afbe: nop
EDIT2
好的,在prepareforsegue方法中釋放位置管理器和Web視圖之后,它就可以工作了。
放松之前,您需要停止位置管理器。
展開時,實際上是在卸載和釋放要從中展開的ViewController。
但是,因為它是locationManager的委托,所以位置管理器正在嘗試將信息傳遞給它。
您應該可以通過...解決此問題
[locationManager stopUpdatingLocation];
在放松之前。 (可能在prepareForSegue方法中)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.