views:

226

answers:

1

Hi,

I have following View COntroller structure:

ScrollViewController LandscapeViewController PortraitViewController

Each with its own .nib

The app starts in landscape mode where many landscape views are added to a scrollview. Each landscape view has its specific portrait view, so I have to assign like ID's to each of this views. Can you tell me, how I can load the specific portrait view for each landscape view when rotating the device?

Do I have to make two scroll views? One for landscape, one for portrait? Or is it possible to just scroll through the landscape scrollview an load just one portrait view with the right content based on an ID? How could I implement that?

The data comes from a property list.

Thanks in advance!

A: 

You use the shouldAutorotateToInterfaceOrientation in your UIViewController to provide the functionality that you are looking for. In the example below I am switching the views to correspond to orientation changes:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) {
    /* Switch to the portrait view or do any other custom layout changes for current Orientation */
    self.view = portraitView;
} else if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
    /* Switch to the landscape view or do any other custom layout changes for current Orientation */
    self.view = landscapeView;
}   
return YES;

}

In your case, you can use the shouldAutorotateToInterfaceOrientation to may be resize your views or switch to their corresponding portrait views.

Hope that helps.

umerh