Ios 不需要的约束个人热点开始栏
在设备中启动应用程序后, 如果显示个人热点, 控制台中的xcode写入:Ios 不需要的约束个人热点开始栏,ios,objective-c,uiviewcontroller,ios-autolayout,Ios,Objective C,Uiviewcontroller,Ios Autolayout,在设备中启动应用程序后, 如果显示个人热点, 控制台中的xcode写入: 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 whi
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.
(
"<NSLayoutConstraint:0x146dd7cf0 V:|-(20)-[UIInputSetContainerView:0x146dd43e0] (Names: '|':UITextEffectsWindow:0x146dd2ee0 )>",
"<NSLayoutConstraint:0x146dbd950 'UIInputWindowController-top' V:|-(0)-[UIInputSetContainerView:0x146dd43e0] (Names: '|':UITextEffectsWindow:0x146dd2ee0 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x146dd7cf0 V:|-(20)-[UIInputSetContainerView:0x146dd43e0] (Names: '|':UITextEffectsWindow:0x146dd2ee0 )>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
但是有没有办法消除热点/incall约束
我希望当hotspot/incall处于活动状态时,view.frame.origin也将为0,0。您可以尝试侦听此方法将更改UIApplicationLegate的StatusBarFrame以更改状态栏的帧,并相应地修改视图位置: 在通话过程中,iPhone SE中新的、已更改的状态栏框架如下所示:
CGRect (origin = (x = 0, y = 0), size = (width = 320, height = 40))
此时状态栏处于正常状态:
CGRect (origin = (x = 0, y = 0), size = (width = 320, height = 20))
因此,当设备处于调用状态时,您只需将视图的y值偏移+20点,或将其设置为0,就像您最初希望的那样并进行修复。这是响应状态栏帧更改而更改帧的正确/干净方法。这比在viewDidLayoutSubviews中设置视图的框架要好
但是,您可以根据需要在willChangeStatusBarFrame中使用以下代码尝试打破约束,但不建议这样做,因为我们正在打破由UIKit设置的约束,这可能会导致问题。通过迭代应用程序的窗口数组,我们基本上打破了uitextfectswindow的限制:
目标-C
迅捷的
谢谢,但我已经用fix解决了这个问题。我想要干净的方式。也就是说,尝试摆脱不需要的约束我的应用程序不使用自动布局,也许这会使uiview始终为0,0你知道如何摆脱约束吗?我尝试了几件事都没有成功。我看不出uiview by defualt需要更改其原点的任何原因,因为有调用,因为没有调用时,状态栏为20,uiview为0,0,这可能是因为有调用时视图被限制降低的方式。在你的警告信息中,打破限制似乎是苹果公司的一个缺陷。请检查编辑后的答案。我稍后会检查并更新。但是,你涵盖了一切。谢谢
CGRect (origin = (x = 0, y = 0), size = (width = 320, height = 20))
- (void)application:(UIApplication *)application willChangeStatusBarFrame:(CGRect)newStatusBarFrame {
for(UIWindow *window in [[UIApplication sharedApplication] windows]) {
if([window.class.description containsString:@"UITextEffectsWindow"]) {
[window removeConstraints:window.constraints];
}
}
}
func application(_ application: UIApplication, willChangeStatusBarFrame newStatusBarFrame: CGRect) {
for window in UIApplication.shared.windows {
if window.self.description.contains("UITextEffectsWindow") {
window.removeConstraints(window.constraints)
}
}
}