【发布时间】:2023-03-26 11:27:02
【问题描述】:
在我的程序中,我有 14 个不同的按钮,每个按钮都有一个字母。每个按钮都通过自动布局相互连接。所以有很多疯狂的限制。解释见第一张图:
但我希望能够通过UIAnimation 来回移动每个按钮,而不会弄乱整个自动布局设置。请参阅第二张图片以获得解释,我想要做什么:
现在是我目前用来获取这些动画的代码:
self.letterA.translatesAutoresizingMaskIntoConstraints = YES;
[UIView animateWithDuration:0.2 animations:^{
[letterA setFrame:CGRectMake(x, y, width, height)];
}];
现在程序完美运行!绝对没有问题!但唯一的“问题”是这段代码在控制台中生成了这条消息:
Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
而且这个警告/错误/问题会不断地重复,每次移动一个UIButton。现在我该怎么办?
- 我可以忽略
Unable to simultaneously satisfy constraints吗?还是会在未来造成麻烦? - 如果不是,如何解决?而且由于涉及到大量的约束,如何在不编辑每个约束的情况下修复它?
- 我非常想继续使用
setFrame:制作动画
【问题讨论】:
标签: ios objective-c uibutton autolayout uianimation