我在我的api调用机制中使用了一个活动指示器,同时隐藏了HUD代码崩溃并发出错误“ [UIActivityIndicatorView release]:消息发送到解除分配的实例”。 / p>
这是堆栈:
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=1, subcode=0x18a5e6ea8)
* frame #0: 0x000000018a5e6ea8 CoreFoundation`___forwarding___ + 744
frame #1: 0x000000018a4e2d4c CoreFoundation`_CF_forwarding_prep_0 + 92
frame #2: 0x000000018a4c2a80 CoreFoundation`-[__NSArrayI dealloc] + 84
frame #3: 0x0000000189062134 libobjc.A.dylib`(anonymous namespace)::AutoreleasePoolPage::pop(void*) + 836
frame #4: 0x0000000190711c3c UIKit`-[UIView dealloc] + 1604
frame #5: 0x0000000189062134 libobjc.A.dylib`(anonymous namespace)::AutoreleasePoolPage::pop(void*) + 836
frame #6: 0x000000018a4beb28 CoreFoundation`_CFAutoreleasePoolPop + 28
frame #7: 0x000000018a58ecec CoreFoundation`__CFRunLoopRun + 1580
frame #8: 0x000000018a4beda4 CoreFoundation`CFRunLoopRunSpecific + 424
frame #9: 0x000000018bf28074 GraphicsServices`GSEventRunModal + 100
frame #10: 0x0000000190779058 UIKit`UIApplicationMain + 208
frame #11: 0x0000000100147448 GraspIO-Dev`main at AppDelegate.swift:14
frame #12: 0x00000001894cd59c libdyld.dylib`start + 4
我无法得到我正在犯的错误,这是我的节目和隐藏代码。
func execute( _ params : String..., serverResponse: @escaping (ServerResponseModel) -> Void) {
//print("params:\(params)");
if self.mCallingView != nil {
DispatchQueue.main.async{
self.showLoadingHUD()
}
}
}
makeWebServiceCall(params){
response in
//print("\n\n response: \(response)")
DispatchQueue.main.async {
serverResponse(response!)
if self.mCallingView != nil {
self.hideLoadingHUD()
}
}
}
}
fileprivate func showLoadingHUD() {
let hud = MBProgressHUD.showAdded(to: mCallingView!, animated: true)
hud.label.text = "Please wait..."
}
fileprivate func hideLoadingHUD() {
let _ = MBProgressHUD.hide(for: mCallingView!, animated: true)
mCallingView!.isUserInteractionEnabled = true
mCallingView = nil
}
应用程序会在隐藏HUD时崩溃,堆栈中的研究是否已溢出但无法找到解决方案。
答案 0 :(得分:0)
该错误非常具有描述性。 您正在尝试设置已经发布的nil。 现在你需要找到你正在做的地方以及避免这种情况的方法。如你所说,你在隐藏它的过程中得到了这个。所以你已经把问题归结为此。
fileprivate func hideLoadingHUD() {
let _ = MBProgressHUD.hide(for: mCallingView!, animated: true)
mCallingView!.isUserInteractionEnabled = true
mCallingView = nil
}
下面。您正试图制作mCallingView = nil
。删除此行并检查是否收到错误。你真的需要将源视图设为nil,同时隐藏活动指示符吗?