【发布时间】:2016-12-31 14:07:13
【问题描述】:
我正在为 iPhone 开发一个 iMessage 应用程序。它目前允许用户按箭头将应用程序的大小从键盘大小调整为全屏。对于我的应用,不需要全屏视图。
是否可以在 iMessage 应用程序中禁用调整大小?
谢谢
【问题讨论】:
我正在为 iPhone 开发一个 iMessage 应用程序。它目前允许用户按箭头将应用程序的大小从键盘大小调整为全屏。对于我的应用,不需要全屏视图。
是否可以在 iMessage 应用程序中禁用调整大小?
谢谢
【问题讨论】:
恐怕这个箭头总是会调用全屏布局。你必须同时处理这两个问题。 但这里有一些想法:
didTransition(to: MSMessagesAppPresentationStyle)。所以你可以requestPresentationStyle(_ presentationStyle: MSMessagesAppPresentationStyle) 使用紧凑模式。这样当它尝试全屏时,它会回到紧凑模式requestPresentationStyle(_ presentationStyle: MSMessagesAppPresentationStyle) 来始终呈现紧凑模式,而不是扩展模式。他们这样说:
但是,请注意,用户应该对 扩展的展示风格。如果用户选择更改 演示风格,您应该尊重这种选择。
【讨论】:
除了上面的:-当人回复消息时,还有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
}
【讨论】: