Вращение iPad, любой способ загрузить пользовательский вид на основе ориентации?

StackOverflow https://stackoverflow.com/questions/3125768

Вопрос

Я пишу приложение, которое я хотел бы отобразить разные взгляды на основе ориентации. Например, если устройство является портретной нагрузкой PView, если ландшафтная нагрузка LVIED. Ниже приведен код IVE в настоящее время.

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)
interfaceOrientation duration:(NSTimeInterval)duration {
 if (interfaceOrientation == UIInterfaceOrientationPortrait)
{
      self.view = portrait;
}
 else if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){
      self.view = portrait;
 }
 else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight){
      self.view = portrait;
 }
 else if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft){
      self.view = landscape;
 }

}

С этим я создал 2 просмотра в IB и подключил розетки справа. Ive также попробовал это:

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)
interfaceOrientation duration:(NSTimeInterval)duration {
 if (interfaceOrientation == UIInterfaceOrientationPortrait)
{
      self.view = portrait;
}
 else if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){
      self.view = portrait;
 }
 else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight){
      lView *abo = [[lView alloc] initWithNibName:@"lView" bundle:nil];
      [self.navigationController pushViewController:abo animated:NO];
      [abo release];

 }
 else if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft){
      lView *abo = [[lView alloc] initWithNibName:@"lView" bundle:nil];
      [self.navigationController pushViewController:abo animated:NO];
      [abo release];

 }

}

Код непосредственно выше работал для iPod, но не iPad. Есть идеи?

Это было полезно?

Решение

Я нашел следующие 2 (Apple) примерных проектов, полезных:

http://developer.apple.com/Library/ios/#samplecode/alternateViews/introduction/intro.html.

http://developer.apple.com/library/ios/#samplecode/whichwayisup/introduction/intro.html.

Кроме того, помните с точки зрения устройства, также ориентированы на лицевой стороне и лицевой стороной; Это поймало меня.

Другие советы

Я должен задать очевидный вопрос:

У вас есть коммутатор замка ориентации экрана включен для вашего iPad?

В зависимости от того, что вы пытаетесь сделать, вы можете настроить свой интерфейс в IB для автоматически обработки вращений. Вы можете изменить размер компонентов, перемещать фото и этикетки вокруг, подобные вещи. Это может сделать то, что вы хотите сделать ...

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top