【问题标题】:Disable iMessage App Resizing禁用 iMessage 应用程序调整大小
【发布时间】:2016-12-31 14:07:13
【问题描述】:

我正在为 iPhone 开发一个 iMessage 应用程序。它目前允许用户按箭头将应用程序的大小从键盘大小调整为全屏。对于我的应用,不需要全屏视图。

是否可以在 iMessage 应用程序中禁用调整大小?

谢谢

【问题讨论】:

    标签: ios swift imessage


    【解决方案1】:

    恐怕这个箭头总是会调用全屏布局。你必须同时处理这两个问题。 但这里有一些想法:

    • 当用户点击箭头时,它会触发方法 didTransition(to: MSMessagesAppPresentationStyle)。所以你可以requestPresentationStyle(_ presentationStyle: MSMessagesAppPresentationStyle) 使用紧凑模式。这样当它尝试全屏时,它会回到紧凑模式
    • 我也不确定,但您可以使用 requestPresentationStyle(_ presentationStyle: MSMessagesAppPresentationStyle) 来始终呈现紧凑模式,而不是扩展模式。

    也看看这里:https://developer.apple.com/reference/messages/msmessagesappviewcontroller/1649184-requestpresentationstyle

    他们这样说:

    但是,请注意,用户应该对 扩展的展示风格。如果用户选择更改 演示风格,您应该尊重这种选择。

    【讨论】:

    • 好的。我会看看。谢谢。
    • 那么您找到解决问题的方法了吗?
    【解决方案2】:

    除了上面的:-当人回复消息时,还有2个场景

    活动和非活动状态:-

    Active 状态的生命周期

    iMessage 点击 

      func willTransition(到presentationStyle: MSMessagesAppPresentationStyle) 

    func didSelect(_ message: MSMessage, conversation: MSConversation) 

      func didTransition(到presentationStyle: MSMessagesAppPresentationStyle)

    InActive 状态的生命周期

    iMessage 点击   

     didBecomeActive(对话:MSConversation) func viewWillAppear(_ animated: Bool) 

      func viewDidAppear(_ animated: Bool)

    所以在非活动状态 willTransition 将接管它。

    但在活动状态,您无法控制Transition,因此默认情况下它将以展开形式打开。在 didBecomeActive 方法中,您必须调用以下函数才能转换为不同的样式。

    这些函数将有助于在 MessagesViewController 中从一种过渡状态转移到另一种过渡状态:-

       requestPresentationStyle(.expanded) 
       requestPresentationStyle(.compact)
    

    上面的方法会调用 willTransition 和 didTransition:-

      override func willTransition(to presentationStyle: MSMessagesAppPresentationStyle) {
    
      //Here we can check the presentationStyle and move the Controller according to    need . i.e
    
        let controller: UIViewController
        if presentationStyle == .compact {
            controller = instantiateCompactController()
        }
        else {
            controller = instantiateExpandController()
        }
    
     //and then Present Controller 
    
    }
    

    更多信息: https://developer.apple.com/videos/play/wwdc2016/224/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-10-04
      • 2011-10-15
      • 1970-01-01
      • 1970-01-01
      • 2011-10-13
      • 2018-01-26
      • 2010-12-12
      相关资源
      最近更新 更多