2
即使設備旋轉(縱向 - >橫向 - >縱向),我也需要始終以橫向模式錄製視頻。在橫向錄製視頻始終是設備正在旋轉(橫向 - >縱向 - >橫向)
取角度很簡單,即時使用hyroscope。我的問題是始終在橫向錄製視頻。任何需要的建議。
我使用AVCaptureSession
來錄製視頻。 AVMutablecomposition?我不知道該用什麼...... 請幫我,請
即使設備旋轉(縱向 - >橫向 - >縱向),我也需要始終以橫向模式錄製視頻。在橫向錄製視頻始終是設備正在旋轉(橫向 - >縱向 - >橫向)
取角度很簡單,即時使用hyroscope。我的問題是始終在橫向錄製視頻。任何需要的建議。
我使用AVCaptureSession
來錄製視頻。 AVMutablecomposition?我不知道該用什麼...... 請幫我,請
爲什麼不強制你的控制器只能在橫向模式?
你可以這樣說:
- (BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskLandscapeLeft;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeRight;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
你可以試試這個代碼
@implementation PortraitViewController
- (void)awakeFromNib
{
isShowingLandscapeView = NO;
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(orientationChanged:)
name:UIDeviceOrientationDidChangeNotification
object:nil];
}
- (void)orientationChanged:(NSNotification *)notification
{
UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
if (UIDeviceOrientationIsLandscape(deviceOrientation) &&
!isShowingLandscapeView)
{
[self performSegueWithIdentifier:@"DisplayAlternateView" sender:self];
isShowingLandscapeView = YES;
}
else if (UIDeviceOrientationIsPortrait(deviceOrientation) &&
isShowingLandscapeView)
{
[self dismissViewControllerAnimated:YES completion:nil];
isShowingLandscapeView = NO;
}
}
也對蘋果的文檔HERE查看詳細轉動實現的樣子。
但是當我從cameara卷看它的視頻旋轉。必須平行於水平線 – user3419170
規格:當我們使用原生ios相機記錄。當我們錄製視頻並旋轉屏幕上的設備視頻不旋轉時,但當我們觀看他時,視頻會在播放器上旋轉。我想製作一些像錄製視頻一樣的東西(視頻錄製,當設備旋轉時不旋轉,在播放器視頻不旋轉時,它將並行到水平) – user3419170
好了。當用戶開始錄製視頻時,您必須鎖定旋轉角度。我想你應該允許旋轉而不錄製。 –