I have a fairly simple view hierarchy in my iPad app.
Window -> RootView -> TableView / DetailView
TableView and DetailView are siblings added as subviews (as per a solution to a previous question). On launch TableView is in front. When you select a cell then method in the app delegate is called which swap them out putting DetailView at the front. A close button in DetailView does the reverse.
Works great.
However... DetailView contains a UIScrollView, drawn in the .xib When DetailView comes to the front I have a method that receives details of the contents of the cell whose selection triggered the change. This populates the detail view with label contents and an image. The labels are simple setters to IBOutlets to the labels in the .xib The image is sized to the height of the UIScrollView, maintaining aspect ratio. This is done programatically, adding it to an UIImageView which is added to the UIScrollView.
The behaviour I have is fine for Portrait. When it rotates to Landscape I want to resize the image to match the width of the enclosing UIImageView (and subsequently the enclosing UIScrollView). I have some great code to actually resize the image (courtesy of a category addition to UIImage from [link text][1]
THE PROBLEM... Only the RootViewController responds to calls to didRotateToInterfaceOrientation. I need to send a message from this to a method on the DetailViews controller telling it to resize the image then redraw the associated UIImageView. Referencing the controller of a subview seems like it should be simple and possibly i'm missing an easy answer. I tried to use:
[[self.view.subviews objectAtIndex:1] didRotateFromInterfaceOrientation:fromInterfaceOrientation];
and
[self.view viewWithTag:[[self.view.subviews objectAtIndex:1] tag]]
But they both return the view NOT the views controller, and therefore get all angry about selectors when I try to run it.
Can anyone point me the right way?