Bellow我有一个错误,由于在movieconntroller视图中添加了一个导航栏,导致我的应用程序崩溃。我的代码如下所示:
Bar = UINavigationBar
-(void) viewWillAppear:(BOOL)animated{
Bar.hidden = YES;
}
-(void)viewDidDisappear:(BOOL)animated{
if (movieController.fullscreen) {
Bar.hidden = YES;
}
}
- (void)MPMoviePlayerDidExitFullscreen:(NSNotification *)notification
{
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerDidExitFullscreenNotification
object:nil];
Bar.hidden = NO;
NSLog(@"calling mpmovieplayer exit");
}
当我添加我的movieconntrollerview时,我使用:
[[[UIApplication sharedApplication] keyWindow] addSubview:Bar];
这是错误:
*** Terminating app due to uncaught exception 'NSGenericException', reason: 'Unable to install constraint on view. Does the constraint reference something from outside the subtree of the view? That's illegal. constraint:<NSLayoutConstraint:0x9863560 H:|-(0)-[UINavigationBar:0x9847d40] (Names: '|':UIWindow:0x98236c0 )> view:<UIView: 0x9867e00; frame = (0 0; 320 480); autoresize = W+H; layer = <CALayer: 0x9867e60>>'
*** First throw call stack:
(0x23c4012 0x144fe7e 0x23c3deb 0x10024a0 0x8cd83e 0x8cda27 0x3e0594 0x3dbf96 0x3e24a4 0x3da89d 0x454486 0x681f44 0x6814ee 0x47f401 0x47e8bd 0x47f5cb 0x162e6d 0x15ed54 0x166bf1 0x70851 0x1463705 0x3972c0 0x397258 0x458021 0x45857f 0x4576e8 0x3c6cef 0x3c6f02 0x3a4d4a 0x396698 0x1c66df9 0x1c66ad0 0x2339bf5 0x2339962 0x236abb6 0x2369f44 0x2369e1b 0x1c657e3 0x1c65668 0x393ffc 0x837d 0x1cf5)
libc++abi.dylib: terminate called throwing an exception
(lldb)
答案 0 :(得分:-1)
我最不得不做的就是在导航栏上关闭auto layout
itselfe