0

我正在尝试从消息中打开 url,我正在使用 3.0.0-beta-swift5 版本的 MessageKit。我实现了委托方法。

    func detectorAttributes(for detector: DetectorType, and message: MessageType, at indexPath: IndexPath) -> [NSAttributedString.Key: Any] {
     switch detector {
     case .hashtag, .mention, .url: return [.foregroundColor: UIColor.blue]
     default: return MessageLabel.defaultAttributes
     }
   }

 func enabledDetectors(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> [DetectorType] {
     return [.url, .address, .phoneNumber, .date, .transitInformation, .mention, .hashtag]
 }

我实现了 didSelectURL 但它没有触发。

func didSelectURL(_ url: URL) {
        let config = SFSafariViewController.Configuration()

        let vc = SFSafariViewController(url: url, configuration: config)
        present(vc, animated: true)
}
4

0 回答 0