Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

横竖屏切换崩溃 #11

Open
wlinshicong opened this issue Sep 20, 2017 · 2 comments
Open

横竖屏切换崩溃 #11

wlinshicong opened this issue Sep 20, 2017 · 2 comments

Comments

@wlinshicong
Copy link

利用AVCaptureConnection,设置了横屏状态下的videoConnection.videoOrientation = AVCaptureVideoOrientationLandscapeRight,横竖屏切换N次之后会崩溃

could not load any Objective-C class information. This will significantly reduce the quality of type information available.

@wlinshicong
Copy link
Author

在AVCaptureViewController的viewDidLoad里加入[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidChangeStatusBarOrientationNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {

    //UIDeviceOrientationFaceUp
    switch ([UIApplication sharedApplication].statusBarOrientation) {
        case UIInterfaceOrientationLandscapeLeft:

// stuckview.affineTransform = CGAffineTransformMakeRotation(M_PI+ M_PI_2); // 270 degress
weakSelf.videoConnection.videoOrientation = AVCaptureVideoOrientationLandscapeLeft;
NSLog(@"横屏 左侧");
break;
case UIInterfaceOrientationPortrait:
// stuckview.affineTransform = CGAffineTransformMakeRotation(M_PI_2); // 90 degrees
weakSelf.videoConnection.videoOrientation = AVCaptureVideoOrientationPortrait;
NSLog(@"竖屏向下x");

            break;
        case UIInterfaceOrientationLandscapeRight:

// stuckview.affineTransform = CGAffineTransformMakeRotation(M_PI); // 180 degrees
weakSelf.videoConnection.videoOrientation = AVCaptureVideoOrientationLandscapeRight;

            NSLog(@"竖屏向下");
            break;
        default:
            NSLog(@"qita");
            break;
    }
}];

声明
@Property (strong, nonatomic) AVCaptureConnection *videoConnection;//视频录制连接
懒加载了videoConnection
//视频连接

  • (AVCaptureConnection *)videoConnection {
    _videoConnection = [self.videoDataOutput connectionWithMediaType:AVMediaTypeVideo];
    return _videoConnection;
    }

@wlinshicong
Copy link
Author

复现流程:横屏启动程序-》点击开始——》转屏到竖屏——》崩溃
如果是让ipad保持竖屏,然后启动程序,好像怎么转都不会崩溃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant