自动布局:在单独的窗口两种观点之间创建约束 [英] Auto Layout: Create constraint between two views in separate windows

查看:78
本文介绍了自动布局:在单独的窗口两种观点之间创建约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能以编程方式创建可在单独的窗口两种观点之间的约束?

Is it possible to programmatically create a constraint between two views that are in separate windows?

如果是的话,我能想到的一个可能的改进到回答的UIView键盘顶部类似的iMessage应用程序

If it is, then I can think of a possible improvement to an answer to "UIView atop the Keyboard similar to iMessage App".

我可以设置 tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeInteractive ,其中的tableView 显示的消息,并使用 dummyInputAccessoryView 。然后,我想用自动布局 dummyInputAccessoryView 的高度限制到包含<$ C栏的$ C> inputTextView &安培; sendButton 和工具栏到的的 dummyInputAccessoryView `

I could set tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeInteractive, where tableView displays the messages, and use a dummyInputAccessoryView. Then, I want to use Auto Layout to constrain the height of dummyInputAccessoryView to that of toolbar, which contains inputTextView & sendButton, and the top oftoolbarto that ofdummyInputAccessoryView`.

推荐答案

没有,我不认为在不同的窗口两个视图可以参与同一个约束,因为我不认为单独的窗口中可以​​有一个共同的祖先视图

No, I don't think two views in separate windows can be involved in the same constraint because I don't think separate windows can have a common ancestor view.

要进行约束有效时,必须将其添加到视图。保存约束的视图必须的约束涉及意见祖先,平时应该是最接近共同祖先。 (这是字的祖先,其中一个观点是它本身的祖先现有的NSView API感。)的约束是该视图的坐标系中PTED间$ P $。

To make a constraint active, you must add it to a view. The view that holds the constraint must be an ancestor of the views the constraint involves, and should usually be the closest common ancestor. (This is in the existing NSView API sense of the word ancestor, where a view is an ancestor of itself.) The constraint is interpreted in the coordinate system of that view.

这篇关于自动布局:在单独的窗口两种观点之间创建约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆