{"bundleID":"com.enterprise.kiwi","app_name":"kiwi","bug_type":"109","name":"kiwi","os_version":"iPhone OS 7.1.1 (11D201)","version":"1190 (3.1.0)"}IncidentIdentifier:FE85E864-393C-417D-9EA0-B4324BEEDA2FCrashReporterKey:a54805586b9487c324ff5f42f4ac93dabbe9f23eHardwareModel:iPhone6,1Process:kiwi[1074]Path:/var/mobile/Applications/D81CE836-3F88-481C-AA5A-21DA530234E0/kiwi.app/kiwiIdentifier:com.yy.enterprise.kiwiVersion:1190(3.1.0)CodeType:ARM-64(Native)ParentProcess:launchd[1]Date/Time:2015-09-0815:44:57.327+0800OSVersion:iOS7.1.1(11D201)ReportVersion:104ExceptionType:EXC_CRASH(SIGSEGV)ExceptionCodes:0x0000000000000000,0x0000000000000000TriggeredbyThread:1Thread0:0libobjc.A.dylib0x00000001993781dcobjc_msgSend+281UIKit0x000000018feacf14-[UIResponder(Internal)_canBecomeFirstResponder]+202UIKit0x000000018feacba0-[UIResponderbecomeFirstResponder]+2403UIKit0x000000018feacfa0-[UIView(Hierarchy)becomeFirstResponder]+1204UIKit0x000000018ff320f8-[UITextFieldbecomeFirstResponder]+645UIKit0x000000018ffe4800-[UITextInteractionAssistant(UITextInteractionAssistant_Internal)setFirstResponderIfNecessary]+2086UIKit0x000000018ffe3f84-[UITextInteractionAssistant(UITextInteractionAssistant_Internal)oneFingerTap:]+17927UIKit0x000000018ffcac60_UIGestureRecognizerSendActions+2128UIKit0x000000018fe5929c-[UIGestureRecognizer_updateGestureWithEvent:buttonEvent:]+3769UIKit0x000000019025803c___UIGestureRecognizerUpdate_block_invoke+5610UIKit0x000000018fe1a258_UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks+28411UIKit0x000000018fe18b34_UIGestureRecognizerUpdate+20812UIKit0x000000018fe57b1c-[UIWindow_sendGesturesForEvent:]+100813UIKit0x000000018fe5722c-[UIWindowsendEvent:]+82414UIKit0x000000018fe28b64-[UIApplicationsendEvent:]+25215UIKit0x000000018fe26c54_UIApplicationHandleEventQueue+849616CoreFoundation0x000000018ce1f640__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__+2017CoreFoundation0x000000018ce1e99c__CFRunLoopDoSources0+25218CoreFoundation0x000000018ce1cc34__CFRunLoopRun+62819CoreFoundation0x000000018cd5dc1cCFRunLoopRunSpecific+44820GraphicsServices0x0000000192a45c08GSEventRunModal+16421UIKit0x000000018fe8efd8UIApplicationMain+115222kiwi0x000000010026a2b8main(main.mm:26)23libdyld.dylib0x000000019995ba9cstart+0Thread1Crashed:0libsystem_kernel.dylib0x0000000199a3daa8kevent64+81libdispatch.dylib0x0000000199941998_dispatch_mgr_thread+48
从崩溃记录完全看不出原因,十分坑爹。
2.3 解决方案
方案一:第一次 Pop 不使用动画。
方案二:统一管理 Pop 的调用,如果当前正在 Pop,则下一次 Pop 先入栈;等到 Pop 执行完再执行下一次 Pop。
#pragma mark - UINavigationController-(NSArray*)popToViewController:(UIViewController*)viewControlleranimated:(BOOL)animated{if(!self.isSwitching){return[superpopToViewController:viewControlleranimated:animated];}else{[selfenqueuePopViewController:viewControlleranimate:animated];returnnil;}}-(UIViewController*)popViewControllerAnimated:(BOOL)animated{if(!self.isSwitching){return[superpopViewControllerAnimated:animated];}else{[selfenqueuePopViewController:nilanimate:animated];returnnil;}}#pragma mark - UINavigationControllerDelegate-(void)navigationController:(UINavigationController*)navigationControllerdidShowViewController:(UIViewController*)viewControlleranimated:(BOOL)animated{self.isSwitching=NO;// 显示完毕之后判断是否需要Popif(self.popVCAnimateQueue.count){PopVCInfo*info=[self.popVCAnimateQueuefirstObject];[self.popVCAnimateQueueremoveObjectAtIndex:0];if(info.controller){[self.navigationControllerpopToViewController:info.controlleranimated:info.animate];}else{[self.navigationControllerpopViewControllerAnimated:info.animate];}}}
4. Push 的过程中手势滑动返回
手势滑动返回本质上调用的还是 Pop,所以,同上。
不过,还可以更根本地禁止用户进行这样的操作,也就是在切换过程中禁止滑动返回手势。
123456789101112131415161718192021222324252627
#pragma mark - UINavigationController// Hijack the push method to disable the gesture-(void)pushViewController:(UIViewController*)viewControlleranimated:(BOOL)animated{self.interactivePopGestureRecognizer.enabled=NO;[superpushViewController:viewControlleranimated:animated];}#pragma mark - UINavigationControllerDelegate-(void)navigationController:(UINavigationController*)navigationControllerdidShowViewController:(UIViewController*)viewControlleranimated:(BOOL)animated{self.isSwitching=NO;self.interactivePopGestureRecognizer.enabled=YES;// 显示完毕之后判断是否需要Popif(self.popVCAnimateQueue.count){PopVCInfo*info=[self.popVCAnimateQueuefirstObject];[self.popVCAnimateQueueremoveObjectAtIndex:0];if(info.controller){[self.navigationControllerpopToViewController:info.controlleranimated:info.animate];}else{[self.navigationControllerpopViewControllerAnimated:info.animate];}}}