0

我有几个视图控制器可以展开到根视图控制器。对于大多数视图控制器,展开转场效果很好,不会导致应用程序崩溃。只有使用 CLlocationmanager 的 viewcontrollers 不能执行 unwind segue 到 root viewcontroller。这些是使我的代码有所不同的行:

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

编辑2

好的,在prepareforsegue方法中释放位置管理器和webview后,它就可以工作了。

4

1 回答 1

1

You need to stop the location manager before you unwind.

When you are unwinding you are essentially unloading and releasing the ViewController that you are unwinding from.

But, because it is the locationManager's delegate the location manager is trying to pass info to it.

You should be able to fix this with...

[locationManager stopUpdatingLocation];

before you unwind. (Possibly in the prepareForSegue method).

于 2015-01-30T12:03:55.703 回答