我试过这些代表,但工作不正常。
override func didSelect(_ message: MSMessage, conversation: MSConversation) {
print("DID SELCT")
}
override func willSelect(_ message: MSMessage, conversation: MSConversation) {
print("WILL SELCT")
}发布于 2018-09-13 17:37:36
Q1。如何在对话中检测用户对消息的点击?
A1。在iOS 11和更高版本中,您可以对消息使用实时布局(请参阅类MSMessageLiveLayout (@available(iOS 11.0, *)) )。这样做时,您可以将一个UITapGestureRecognizer实例添加到MSMessagesAppViewController实例的presentationStyle is .transcript (@available(iOS 11.0, *))会话记录中显示的视图中。
请参阅来自What's New in iMessage Apps ( WWDC 2017 - Session 234 - iOS ( https://developer.apple.com/videos/play/wwdc2017/234/?time=1726 )的视频)。在演讲开始的29分钟,你会发现点击手势识别器的讨论。有关如何在.transcript子类的willBecomeActive(with:)方法中检测MSMessagesAppViewController表示样式,请参阅视频前面的内容,并显示适当的子视图控制器。
Q2。如果MessageViewController控制器是紧凑的和用户幻灯片上升,我如何能够检测到?
A2。在您的willTransition(to:)子类中重写MSMessagesAppViewController,如下所示:
override func willTransition(to newPresentationStyle: MSMessagesAppPresentationStyle) {
super.willTransition(to: newPresentationStyle) // don't forget to call super
// note that MSMessagesAppViewController's `presentationStyle` property holds the presentation style BEFORE the transition
print("will transition() from \(presentationStyle.rawValue) to \(newPresentationStyle.rawValue) [0 = .compact, 1 = .expanded, 2 = .transcript]")
if (presentationStyle == .compact && newPresentationStyle == .expanded) {
// handle transition from .compact to .expanded here
}
}https://stackoverflow.com/questions/48032024
复制相似问题