- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个名为 containerView
的 UIView。
我将其作为 subview 添加到 Controller View 的 Root View 中。我以编程方式向它添加了一些约束(我将其居中并使宽度与 super View 的宽度相差几个点)。
我已将一些 UILabel
添加到 containerView
作为 subview 。 UILabel
的高度决定了 containerView
的高度。
当用户点击屏幕时,containerView
会从 CGRectOffset()
向上移动,动画完成后,它会移回到原始位置。
CGPoint absolutePoint = self.containterView.frame.origin;
self.containerYConstraint.constant = -absolutePoint;
[UIView
animateWithDuration:0.5
animations:^
{
[viewForUpdate setNeedsUpdateConstraints];
}
completion:^(BOOL finished)
{
self.containerYConstraint.constant = 0;
[viewForUpdate setNeedsUpdateConstraints];
[self.containerView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)]; // Remove all subviews
}];
我需要删除作为 subview 放入其中的 UILabel
并用不同的标签替换它们。然而,当我删除其中一个 UILabel 时,整个 containerView
就会丢失(我将背景设置为红色,这样我就可以看到它)。我删除了示例中的所有 subview ,但是当我尝试仅删除一个 subview 时,会发生相同的效果。
为什么会出现这种情况?这和自动布局有关系吗?另外,如果我想在删除其中一个 UILabels 后将其重新设置为中心,我该如何重新进行约束?
最佳答案
在使用 AutoLayout 时修改框架是一个禁忌。一旦您开始使用 AutoLayout,您实际上就是在告诉系统您希望它为您设置框架。
不是直接为框架设置动画,而是创建指向您的约束的属性并为这些约束设置动画。
关于ios - CGRectOffset 后 AutoLayout 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27432564/
尝试滑动一个单元格,另一个 View 就会出现。到目前为止,这是我的代码,但我看不到 rightView。相反,它限制了我看到 leftView(我想要相反的......leftView 甚至不存在)
不确定这是否与我的问题有关,但我有一个动画序列可以移动 UIView使用以下代码超出框架: [UIView animateWithDuration:0.3
我有一个名为 containerView 的 UIView。 我将其作为 subview 添加到 Controller View 的 Root View 中。我以编程方式向它添加了一些约束(我将其居中
我知道这没有任何意义,但我在使用核心数据构建并调用 CGRectOffset 的 iPhone 应用程序中遇到了一个非常奇怪的错误。我的 App Delegate 的 didFinishLaunchi
我是一名优秀的程序员,十分优秀!