
* thread #1: tID = 0x1ee50f,0x00000001096f5d05 libswiftFoundation.dylib`static Foundation.DateComponents._unconditionallyBrIDgeFromObjectiveC (Swift.Optional<__ObjC.NSDateComponents>) -> Foundation.DateComponents with unmangled suffix "_merged" + 85,queue = 'com.apple.main-thread',stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP,subcode=0x0)frame #0: 0x00000001096f5d05 libswiftFoundation.dylib`static Foundation.DateComponents._unconditionallyBrIDgeFromObjectiveC (Swift.Optional<__ObjC.NSDateComponents>) -> Foundation.DateComponents with unmangled suffix "_merged" + 85frame #1: 0x000000010558e36f Invest`@objc InvestDashboard.textVIEw(UITextVIEw,shouldInteractWith : URL,in : _NSRange) -> Bool + 79 at InvestDashboard.swift:0frame #2: 0x000000011fd478fc UIKit`-[UITextVIEwAccessibility accessibilityActivate] + 838frame #3: 0x000000011fed29d2 UIAccessibility`-[NSObject(UIStorage) accessibilityPerformAction:withValue:fencePort:] + 1448frame #4: 0x000000011feaa63d UIAccessibility`_performActionCallback + 163frame #5: 0x000000011fc0cec4 AXRuntime`_AXXMIgperformAction + 107frame #6: 0x000000011fc06f06 AXRuntime`_XPerformAction + 216frame #7: 0x000000011fc16541 AXRuntime`mshMIgperform + 266frame #8: 0x0000000106d1ff89 CoreFoundation`__CFRUNLOOP_IS_CALliNG_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41frame #9: 0x0000000106d1ff01 CoreFoundation`__CFRunLoopDoSource1 + 465frame #10: 0x0000000106d18045 CoreFoundation`__CFRunLoopRun + 2389frame #11: 0x0000000106d17494 CoreFoundation`CFRunLoopRunspecific + 420frame #12: 0x000000010cc38a6f GraphiCSServices`GSEventRunModal + 161frame #13: 0x00000001078c2964 UIKit`UIApplicationMain + 159frame #14: 0x000000010467e99f InvestDemo`main + 111 at AppDelegate.swift:29frame #15: 0x000000010b88268d libdyld.dylib`start + 1frame #16: 0x000000010b88268d libdyld.dylib`start + 1
每当我在TextVIEw上使用activate时会发生这种情况.我尝试了很多不同的东西,比如覆盖accessibilityActivate() – > Bool但应用程序在此方法被调用之前崩溃了.有什么建议?
解决方法 我解决了这个问题并希望分享,以便其他具有同样令人困惑的问题的人可以解决它.首先要做的是继承UITextVIEw,并在该子类中覆盖func accessibilityActivate() – >布尔.然后创建一个委托来处理激活TextVIEw时发生的事情并通过重写方法调用它.
然后根据UIAccessibilityIsVoiceOverRunning()设置TextVIEw的委托,因此如果正在运行语音,则将UITextVIEwDelegate设置为nil,以防止崩溃发生,然后激活 *** 作由您在上面的子类中覆盖的方法处理.最后,为UIAccessibilityVoiceOverStatusChanged设置一个监听器,并在从off到on时将UITextVIEwDelegate设置为nil,并将其设置为相反方案的原始委托类.
一些代码:
//: Playground - noun: a place where people can playimport UIKitclass Test : UITabbarController,UITextVIEwDelegate,ActivationDelegate { var voiceOverRunning : Bool { get { return UIAccessibilityIsVoiceOverRunning() } } var testVIEw = AccessibilityVIEw() overrIDe func vIEwDIDLoad() { if !voiceOverRunning { testVIEw.delegate = self } else { testVIEw.activationDelegate = self } NotificationCenter.default.addobserver( self,selector: #selector(self.dIDChangeVoiceOver),name: NSNotification.name(rawValue: UIAccessibilityVoiceOverStatusChanged),object: nil) } func doStuff() { /* Do what you want to happen here on activation */ } @objc func dIDChangeVoiceOver(){ testVIEw.delegate = voiceOverRunning ? nil : self testVIEw.activationDelegate = voiceOverRunning ? self : nil }}protocol ActivationDelegate : class { func doStuff()}class AccessibilityVIEw : UITextVIEw { var activationDelegate : ActivationDelegate! overrIDe func accessibilityActivate() -> Bool { activationDelegate.doStuff() return true }} 总结 以上是内存溢出为你收集整理的ios – 只要激活带有链接的文本视图,应用程序就会崩溃全部内容,希望文章能够帮你解决ios – 只要激活带有链接的文本视图,应用程序就会崩溃所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)