Ios Avplayer-NSAutoresizingMaskLayoutConstraint错误

Ios Avplayer-NSAutoresizingMaskLayoutConstraint错误,ios,objective-c,avplayer,react-native,Ios,Objective C,Avplayer,React Native,Avplayer工作正常。但是我犯了这个错误。如果禁用“显示播放”控件,则工作时不会出现错误,也不会出现任何问题。但我不能这样做,因为我需要它。包括控制台调试日志和其他代码 谢谢 2015-11-09 06:35:11.019 youapp[6798:2785361] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is

Avplayer工作正常。但是我犯了这个错误。如果禁用“显示播放”控件,则工作时不会出现错误,也不会出现任何问题。但我不能这样做,因为我需要它。包括控制台调试日志和其他代码

谢谢

2015-11-09 06:35:11.019 youapp[6798:2785361] 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:0x7f8164b96f20 h=-&- v=-&- _UIBackdropContentView:0x7f81648b0510.width == _UIBackdropView:0x7f81648af200.width>",
    "<NSLayoutConstraint:0x7f8164986a20 H:|-(0)-[UIView:0x7f8164985420]   (Names: '|':UIView:0x7f816256e810 )>",
    "<NSLayoutConstraint:0x7f8164986a70 H:[UIView:0x7f8164985420]-(0)-|   (Names: '|':UIView:0x7f816256e810 )>",
    "<NSLayoutConstraint:0x7f8164985ed0 H:|-(0)-[UIView:0x7f816256e810]   (Names: '|':AVPlayerView:0x7f8164976610 )>",
    "<NSLayoutConstraint:0x7f8164985f40 H:[UIView:0x7f816256e810]-(0)-|   (Names: '|':AVPlayerView:0x7f8164976610 )>",
    "<NSLayoutConstraint:0x7f8164b66d80 H:|-(0)-[UIView:0x7f81648b01e0]   (Names: '|':_UIBackdropContentView:0x7f81648b0510 )>",
    "<NSLayoutConstraint:0x7f8164b66dd0 H:[UIView:0x7f81648b01e0]-(0)-|   (Names: '|':_UIBackdropContentView:0x7f81648b0510 )>",
    "<NSLayoutConstraint:0x7f8164b66570 H:|-(0)-[_UIBackdropView:0x7f81648af200]   (Names: '|':UIView:0x7f81648a3900 )>",
    "<NSLayoutConstraint:0x7f8164b665c0 H:[_UIBackdropView:0x7f81648af200]-(0)-|   (Names: '|':UIView:0x7f81648a3900 )>",
    "<NSLayoutConstraint:0x7f8164b662b0 H:|-(0)-[UIView:0x7f81648a3900]   (Names: '|':AVAlphaUpdatingView:0x7f81648a3790 )>",
    "<NSLayoutConstraint:0x7f8164b66300 H:[UIView:0x7f81648a3900]-(0)-|   (Names: '|':AVAlphaUpdatingView:0x7f81648a3790 )>",
    "<NSLayoutConstraint:0x7f8164b69fc0 H:|-(14)-[AVButton:0x7f81648b0dd0](LTR)   (Names: '|':UIView:0x7f81648b01e0 )>",
    "<NSLayoutConstraint:0x7f8164b976d0 H:[AVButton:0x7f81648b0dd0]-(15)-[UILabel:0x7f8164a8aad0'0:00'](LTR)>",
    "<NSLayoutConstraint:0x7f8164b97910 H:[UILabel:0x7f8164a8aad0'0:00']-(12)-[AVScrubber:0x7f8164ac0b50](LTR)>",
    "<NSLayoutConstraint:0x7f8164b97960 AVScrubber:0x7f8164ac0b50.right == UILabel:0x7f8164ade4a0'--:--'.left - 12>",
    "<NSLayoutConstraint:0x7f8164b97e20 UILabel:0x7f8164ade4a0'--:--'.right == AVButton:0x7f8164adf1a0.left - 15>",
    "<NSLayoutConstraint:0x7f8164b97ec0 AVButton:0x7f8164adf1a0.right == AVButton:0x7f8164994ad0.left - 10>",
    "<NSLayoutConstraint:0x7f8164b97a00 AVButton:0x7f8164994ad0.right == AVButton:0x7f8164969690.left - 10>",
    "<NSLayoutConstraint:0x7f8164b98150 AVButton:0x7f8164969690.right == UIView:0x7f81648b01e0.right - 14>",
    "<NSLayoutConstraint:0x7f8164af4520 H:|-(0)-[AVAlphaUpdatingView:0x7f81648a3790]   (Names: '|':UIView:0x7f8164985420 )>",
    "<NSLayoutConstraint:0x7f8164af4570 H:[AVAlphaUpdatingView:0x7f81648a3790]-(0)-|   (Names: '|':UIView:0x7f8164985420 )>",
    "<NSLayoutConstraint:0x7f8164b86f20 'UIView-Encapsulated-Layout-Width' H:[AVPlayerView:0x7f8164976610(100)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7f8164b976d0 H:[AVButton:0x7f81648b0dd0]-(15)-[UILabel:0x7f8164a8aad0'0:00'](LTR)>

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.
2015-11-09 06:37:08.097 [warn][tid:com.facebook.React.JavaScript] 'devtools socket closed'

不要每次布局视图控制器的子视图时都设置视图控制器的视图;之前,当然,但是之后没有任何意义。

不要每次布局视图控制器的子视图时都设置视图控制器的视图;当然是之前,但之后没有意义

#import "VideoPlayerView.h"
#import "RCTRootView.h"

@interface VideoPlayerView ()

@property (nonatomic, retain) AVPlayerViewController *avPlayerViewcontroller;
@property (nonatomic, retain) UIView *view;

@end

@implementation VideoPlayerView
{
  UIView *_reactView;
}


- (instancetype)init
{
  if ((self = [super init])) {
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationChange:) name:@"UIDeviceOrientationDidChangeNotification" object:nil];
  }
  return self;

}

- (void)dealloc
{
  [[NSNotificationCenter defaultCenter] removeObserver:self];
}


- (void)setUrl:(NSString *)url {
  AVPlayerViewController *playerViewController = [[AVPlayerViewController alloc] init];

  playerViewController.player = [AVPlayer playerWithURL:[NSURL URLWithString: url]];

  self.avPlayerViewcontroller = playerViewController;
  [self.avPlayerViewcontroller setShowsPlaybackControls:YES];

  self.avPlayerViewcontroller.videoGravity = AVLayerVideoGravityResizeAspect;

  [self addSubview:playerViewController.view];
  self.autoresizesSubviews = TRUE;

  [self.avPlayerViewcontroller.player play];
}

- (void)layoutSubviews
{
  [super layoutSubviews];

  self.avPlayerViewcontroller.view.frame = self.bounds;

}

- (void)viewDidDisappear:(BOOL)animated {
  NSLog(@"test");
}


- (void)deviceOrientationChange:(NSNotification *)notification
{

  UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];

  switch (orientation) {
    case UIDeviceOrientationPortrait:
    case UIDeviceOrientationPortraitUpsideDown:
      self.avPlayerViewcontroller.videoGravity = AVLayerVideoGravityResizeAspect;
      break;
    case UIDeviceOrientationLandscapeLeft:
    case UIDeviceOrientationLandscapeRight:

      self.avPlayerViewcontroller.videoGravity = AVLayerVideoGravityResizeAspectFill;
      break;
    default:
      self.avPlayerViewcontroller.videoGravity = AVLayerVideoGravityResizeAspect;
      break;
  }
}


@end