我有一個視頻應用程序,但我想它僅停留在橫向在目標C中只使用景觀?
當景觀,它看起來是這樣的:
但是,當我轉身,它選擇縱向方向而像這樣:
也只是停留在橫向,已經試了又試,很多事情我已經看到,沒有任何工作,有人幫助我?
[更新]
只需要一個視圖中不使用方向縱向,有人已經有這個問題嗎?
有沒有人有任何其他想法?沒有在這裏工作
[更新] - > 30/09/2015
我的解決方案:
在AppDelegate.m我用這個:
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if(self.restrictRotation == YES)
return UIInterfaceOrientationMaskLandscape;
else
return UIInterfaceOrientationMaskAll;
}
AppDelegate.h:
@property() BOOL restrictRotation;
我想在哪裏只留下山水,我用它(videoViewController.m):
在viewDidLoad中[self restrictRotation:YES];
NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
,並添加方法:
-(void) restrictRotation:(BOOL) restriction
{
AppDelegate* appDelegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
appDelegate.restrictRotation = restriction;
}
記得,如果在videoViewController.h的#進口 「AppDelegate.h」
並且您不想要的視圖鎖定在橫向添加:
在viewDidLoad中:
[self restrictRotation:YES];
和方法:
-(void) restrictRotation:(BOOL) restriction
{
AppDelegate* appDelegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
appDelegate.restrictRotation = restriction;
}
問題解決了! THX所有
請指定*你已經嘗試了什麼,也許還需要添加一些代碼。 – Numbers
我現在想要的是: - (void)viewDidAppear:(BOOL)animated {super viewDidAppear:animated]; NSNumber * value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft]; [[UIDevice currentDevice] setValue:value forKey:@「orientation」]; } –
這是爲了強制旋轉設備旋轉,如果您按照我在答案中提到的步驟操作,則可能不需要此操作。 – baydi