Changing UIView on orientation change?

The best thing you can do is to change the frames of your subview frames according to your interface orientations. You can do it like.

The best thing you can do is to change the frames of your subview frames according to your interface orientations. You can do it like: #pragma mark - #pragma mark InterfaceOrientationMethods - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown || interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft); } //-------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{ super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration; if(toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){ //self. View = portraitView; self changeTheViewToPortrait:YES andDuration:duration; } else if(toInterfaceOrientation == UIInterfaceOrientationLandscapeRight || toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft){ //self.

View = landscapeView; self changeTheViewToPortrait:NO andDuration:duration; } } //-------------------------------------------------------------------------------------------------------------------------------------------------------------------- - (void) changeTheViewToPortrait:(BOOL)portrait andDuration:(NSTimeInterval)duration{ UIView beginAnimations:nil context:NULL; UIView setAnimationDuration:duration; if(portrait){ //change the view and subview frames for the portrait view } else{ //change the view and subview frames for the landscape view } UIView commitAnimations; } Hope this helps, Thanks, Madhup.

That did the trick, thanks! – Designeveloper May 1 '10 at 2:11.

I actually figured out a very simple alternative way around this. Since I am just changing the background image, adding this.. ` - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation duration:(NSTimeInterval)duration { if (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) { brownBackground setImage:UIImage imageNamed:@"Portrait_Background. Png"; } else { brownBackground setImage:UIImage imageNamed:@"Landscape_Background.

Png"; } } ` Changes the background of a declared UIImageView based on orientation. Only downside is, the current background image is not visible in Interface builder as it is handled with code.

One small addition to Madhup's approach, which is great. I found I needed to add this to viewDidLoad to set initial background image for portrait or landscape: // set background image if (self. InterfaceOrientation == UIInterfaceOrientationPortrait || self.

InterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) { self.view. BackgroundColor = UIColor colorWithPatternImage:UIImage imageNamed:@"portraitBG. Png"; } else { self.view.

BackgroundColor = UIColor colorWithPatternImage:UIImage imageNamed:@"landscapeBG. Png"; } thanks again Madhup.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions