全屏uiview没有完美的工作

时间:2017-04-26 13:29:34

标签: xcode uiview autolayout resize

早上好, 我有一个问题,当我试图通过点击缩放按钮传递到一个完整的屏幕。事实上,当我点击按钮显示一个视频和工具栏,允许在视频中移动。它看起来很完美,但我发现当我通过滑块移动到几乎60%的水平时,我无法向前或向后移动。 我认为问题是由于布局设置。 这个代码:

- (void)changeFullScreen:(BOOL)isFullScreen index:(int)index{
if (isFullScreen == YES) {

    CGAffineTransform affineTransforme = CGAffineTransformMakeRotation(M_PI_2);
    //CGFloat scale = [UIScreen mainScreen].bounds.size.height / [UIScreen mainScreen].bounds.size.width;
    //affineTransforme = CGAffineTransformScale(affineTransforme,scale , scale);

    NSIndexPath *indexPath = [NSIndexPath indexPathForItem:index inSection:0];
    EMPOIVideoCell *cell = [poiTableView cellForRowAtIndexPath:indexPath];

    tmpVideoPlayerview = [cell.containerView viewWithTag:101];
    //tmpVideoPlayerview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    tmpVideoPlayerview.transform = affineTransforme;  //CGAffineTransformTranslate(affineTransforme, 190, 0);

    fullScreenView = [[UIViewController alloc] init];
    tmpVideoPlayerview.frame = CGRectMake(-248, 0, fullScreenView.view.bounds.size.height , fullScreenView.view.bounds.size.width);
    tmpVideoPlayerview.videoContainer.frame = tmpVideoPlayerview.frame;

    tmpVideoPlayerview.videoContainer.layer.frame = tmpVideoPlayerview.frame;

    playerLayer = [AVPlayerLayer playerLayerWithPlayer:tmpVideoPlayerview.videoPlayer];
    playerLayer.frame = tmpVideoPlayerview.videoContainer.bounds;
    [tmpVideoPlayerview.avPlayerLayer removeFromSuperlayer];
    [tmpVideoPlayerview.videoContainer.layer addSublayer:playerLayer];
    tmpVideoPlayerview.contentMode = UIViewContentModeScaleToFill;
    //[tmpVideoPlayerview updateConstraints];
    [tmpVideoPlayerview setNeedsLayout] ;
    [tmpVideoPlayerview layoutIfNeeded];
    fullScreenView.view.clipsToBounds = YES;
    [fullScreenView.view addSubview:tmpVideoPlayerview];
    [self addChildViewController:fullScreenView];
    [self.view addSubview:fullScreenView.view];
    //[fullScreenView.view updateConstraints];
    //[fullScreenView.view layoutIfNeeded];
    [[UIApplication sharedApplication] setStatusBarHidden:YES];

}

photo to explain the situation

0 个答案:

没有答案