Я хотел бы обновить свое приложение из устаревшего API
Из этого
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration {
// Camera rotation needs to be manually set when rotation changes.
if (self.previewLayer) {
if (toInterfaceOrientation == UIInterfaceOrientationPortrait) {
self.previewLayer.connection.videoOrientation = AVCaptureVideoOrientationPortrait;
} else if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
self.previewLayer.connection.videoOrientation = AVCaptureVideoOrientationPortraitUpsideDown;
} else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
self.previewLayer.connection.videoOrientation = AVCaptureVideoOrientationLandscapeLeft;
} else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
self.previewLayer.connection.videoOrientation = AVCaptureVideoOrientationLandscapeRight;
}
}
self.dataOutput.previewFrameSize = self.previewLayer.frame.size;
}
к этому
- (void)viewWillTransitionToSize:(CGSize)size
withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator{
// CODES HERE
}
Целью этого изменения является сохранение вращения камеры, ориентация должна быть неизменной. (Я использую EAGL и ручной дисплей AVFoundation в реальном времени).
AV-соединение все еще использует «Ориентацию», но новый API не предлагал их. Во всяком случае перевести его в ??? Спасибо
(также приветствуются коды Swift, мой старый проект написан на obj-c, но да, я могу читать swift)