У меня есть 5 вид в раскадровке. Я хочу, чтобы каждая ориентация вида была другой, например, один вид будет UIInterfaceOrientationLandscapeRight
другой вид будет UIInterfaceOrientationLandscapeLeft
или UIInterfaceOrientationPortrait
или UIInterfaceOrientationPortraitUpsideDown
. Итак, как установить эту ориентацию вида по-разному.set UIInterfaceOrientation во время выполнения
Я использовал [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];
, но он показывает предупреждение «UIDevice может не отвечать на setOrientation». По мнению многих из StackOverflow писателей я использую
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
//return UIInterfaceOrientationLandscapeLeft;
return (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
}
это выше код, но он не работает в моем проекте. Итак, какова правильная процедура ориентации экрана. Спасибо заранее.
Так можно ли программно сохранить мое устройство в портретном режиме? – Banshidhari
Сохранять возврат от shouldAutorotateToInterfaceOrientation ДА для портретной ориентации. – beryllium