我有一个 ios 应用程序,它在 iPhone X 上崩溃,在其他 iPhone 上运行良好。我objective c
用XIB
. 我已经浏览了现有的帖子以解决限制问题。那没有帮助。版本是Xcode
9.1 调试控制台报错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 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)
(
"<NSAutoresizingMaskLayoutConstraint:0x60000028bd60 h=-&- v=-&- _UIBackdropContentView:0x7fb5c34588c0.midY == _UIBackdropView:0x7fb5c3404fa0.midY (active)>",
"<NSAutoresizingMaskLayoutConstraint:0x60000028bc20 h=-&- v=-&- _UIBackdropContentView:0x7fb5c34588c0.height == _UIBackdropView:0x7fb5c3404fa0.height (active)>",
"<NSLayoutConstraint:0x600000484510 V:|-(0)-[UIStatusBar_Modern:0x7fb5c34058f0] (active, names: '|':_UIBackdropContentView:0x7fb5c34588c0 )>",
"<NSLayoutConstraint:0x600000484600 UIStatusBar_Modern:0x7fb5c34058f0.height == 0 (active)>",
"<NSLayoutConstraint:0x6000004845b0 V:[UIStatusBar_Modern:0x7fb5c34058f0]-(0)-[UIView:0x7fb5c3431870] (active)>",
"<NSLayoutConstraint:0x60000028eba0 UIView:0x7fb5c3431870.top == _UIBackdropView:0x7fb5c3404fa0.top + 44 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x6000004845b0 V:[UIStatusBar_Modern:0x7fb5c34058f0]-(0)-[UIView:0x7fb5c3431870] (active)>
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.
发生此问题的代码如下。
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 3.2) {
NSString *baseUrl = [NSString stringWithFormat:@"file://%@//%@", [[NSBundle mainBundle] resourcePath],[self.video valueForKey:@"VideoFile"]];
baseUrl = [baseUrl stringByReplacingOccurrencesOfString:@"/" withString:@"//"];
baseUrl = [baseUrl stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
NewVideoController *videoController = [[[NewVideoController alloc] initWithContentURL:[NSURL URLWithString:baseUrl]] autorelease];
[videoController.view setTranslatesAutoresizingMaskIntoConstraints:YES];
//[videoController.view prepareToPlay];
//[videoController.view setFrame: self.bounds]; // player's frame must match parent's
videoController.view.frame = [[UIApplication sharedApplication]keyWindow].bounds;
//[videoController.view setFrame:CGRectMake(0,150, 320, 200)];
// ...
//[videoController play];
//self.setTranslatesAutoresizingMaskIntoConstraints=YES;
videoController.moviePlayer.useApplicationAudioSession = NO;
//videoController.view.translatesAutoresizingMaskIntoConstraints = NO;
[self presentMoviePlayerViewControllerAnimated:videoController];
}
从这个断点继续后,视频屏幕将显示在技术模拟器上。在真正的 iPhoneX 上它会崩溃。