2010-06-26 4 views
0

Im пишу приложение, которое я хотел бы отображать различные виды на основе ориентации. Например, если устройство представляет собой портретную нагрузку pView, если пейзаж загружается lView. Ниже приведен код, который в настоящее время используется.IPad вращения, любой способ загрузить пользовательский вид на основе ориентации?

- (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]; 

} 

}

код непосредственно выше работал ставку, но не IPad. Есть идеи?

ответ

1

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

http://developer.apple.com/library/ios/#samplecode/AlternateViews/Introduction/Intro.html

http://developer.apple.com/library/ios/#samplecode/WhichWayIsUp/Introduction/Intro.html

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

0

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

У вас есть переключатель блокировки ориентации экрана включен для IPad?

+0

Нет, я пытаюсь загрузить другой вид, основанный на ориентации. – Tanner

0

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

 Смежные вопросы

  • Нет связанных вопросов^_^