在UITextView上按下链接时应用程序崩溃

Mid*_* MP 6 uitextview ios swift

我在我的iOS应用程序中遇到了一个奇怪的错误,它只发生在设备中.在我的应用程序中,我有一个主页,如果用户按下按钮,我将显示一个FormSheet(关于我们页面).

let storyBoard = UIStoryboard(name: "Utility", bundle: nil);
let aboutUsVC  = storyBoard.instantiateViewControllerWithIdentifier("AboutUs") as! AboutUsViewController;
aboutUsVC.modalPresentationStyle = .FormSheet;
aboutUsVC.preferredContentSize   = CGSize(width: 500,height: 400);
self.presentViewController(aboutUsVC, animated: true, completion: nil);
Run Code Online (Sandbox Code Playgroud)

我在我们页面中放置了一个UITextView,并添加了一个链接,因为它的内容: 文本视图中的链接

问题1

当我长按该链接时,我在控制台上收到一条警告消息:

已经呈现的<_UIRotatingAlertController:0x13e107200>

问题2

长按后如果再次点击链接,应用程序崩溃并显示以下消息:

2016-03-16 18:11:37.022 MyApp [938:400786]***断言失败 - [UITextView startInteractionWithLinkAtPoint:],/ BuildRoot/Library/Caches/com.apple.xbs/Source/UIKit/UIKit-3512.29. 5/UITextView_LinkInteraction.m:377

2016-03-16 18:11:37.023 MyApp [938:400786]***由于未捕获的异常'NSInternalInconsistencyException'终止应用程序,原因:''***首先抛出调用堆栈:(0x184220f48 0x198e47f80 0x184220e18 0x185114a1c 0x18a12de50 0x189d38be4 0x189d2f330 0x189958b5c 0x1897e685c 0x189d3070c 0x1897a58b8 0x1897a263c 0x1841d7bd0 0x1841d5974 0x1841d5da4 0x184104ca0 0x18f184088 0x18981cffc 0x100188368 0x19968a8b8)libc ++ abi.dylib:以NSException类型的未捕获异常终止

我认为UIKit造成了这次崩溃.我该如何修复这次崩溃?

更多信息:

  1. 基础SDK:9.2
  2. 部署目标:8.1
  3. Xcode版本:7.2.1
  4. iOS设备操作系统版本:9.1

Mid*_* MP 6

正如Apple论坛帖子所述,我实现了以下内容UITextViewDelegate,它解决了我的问题

func textView(textView: UITextView, shouldInteractWithURL URL: NSURL, inRange characterRange: NSRange) -> Bool
{
    UIApplication.sharedApplication().openURL(URL)
    return false  
}  
Run Code Online (Sandbox Code Playgroud)

@Louis Tur:谢谢你的链接