1

Well, I have a view controller that will control all subviews for my app (I hope). When initWithNibName: is called, the first view is displayed fine. When I press a button in that view it calls - (IBAction)pause:(id)sender. In this I have self.view = pauseView, pauseView being a UIView defined with IBOutlet. When that UIView is displayed, it is displayed with Portrait Orientation, even though the resizing function in the view controller is defined correctly and the iphone simulator is rotated the right way (and also the orientation is portrait in Interface Builder). In other words, everything is sideways from the user's perspective. How do I fix this?

2 Answers 2

1

The pause view isn't receiving rotation events from the view controller. Only its view property will receive those events. Put your pauseView as a subview to the main view, but set it to hidden. You'll need to do this in the XIB file, drag and drop the pauseView into the view and find the hidden property and set that to on.

Change your button to:

- (IBAction)pause:(id)sender { [pauseView setHidden:NO]; } 
Sign up to request clarification or add additional context in comments.

2 Comments

This is very useful insight. I have one question: you said only the view property receives rotation events, well when I do "self.view = pauseView", doesn't that mean self.view points to the pauseView? In which case the new self.view (its a PauseView now) will receive rotation events?
I finally found a really nice solution: [playView addSubview:pauseView]
1

Try allowing autorotation:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } 

Comments