首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Swift 3: iMessage扩展检测用户点击消息和检测手动幻灯片

Swift 3: iMessage扩展检测用户点击消息和检测手动幻灯片
EN

Stack Overflow用户
提问于 2017-12-30 07:45:42
回答 1查看 791关注 0票数 1
  1. 如何在对话中检测用户对消息的点击?
  2. 如果MessageViewController控制器是紧凑的和用户幻灯片上升,我如何能够检测到?

我试过这些代表,但工作不正常。

代码语言:javascript
复制
override func didSelect(_ message: MSMessage, conversation: MSConversation) {
   print("DID SELCT")
}
override func willSelect(_ message: MSMessage, conversation: MSConversation) {
    print("WILL SELCT")
}
EN

回答 1

Stack Overflow用户

发布于 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,如下所示:

代码语言:javascript
复制
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

    }
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48032024

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档