Hi experts,
When i change the orientation say from Portrait to Landscape mode, how do i change the background image of a UIImageView which is inside a view?
I have two images
Login-iPad-Portrait.png - 768 × 1004 and
Login-iPad-Landscape.png - 1024 × 748
So in IB, i set the background of the imageview to 'Login-iPad-Portrait.png'
And in the code, this is what i do
But the 'willRotateToInterfaceOrientation' event is never triggered, even as i change the orientation. Thus the orientation specific image is not updated.
Any pointers to what am doin wrong?
Or is there any other way of doing this?
Thanks in Advance!
When i change the orientation say from Portrait to Landscape mode, how do i change the background image of a UIImageView which is inside a view?
I have two images
Login-iPad-Portrait.png - 768 × 1004 and
Login-iPad-Landscape.png - 1024 × 748
So in IB, i set the background of the imageview to 'Login-iPad-Portrait.png'
And in the code, this is what i do
Code:
Code:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for iPAD
return YES;
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
if(toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
backgroungImage.image = [UIImage imageNamed:@"Login-iPad- Portrait.png"];
}
else if(toInterfaceOrientation == UIInterfaceOrientationLandscapeRight || toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft)
{
backgroungImage.image = [UIImage imageNamed:@"Login-iPad-Landscape.png"];
}
}
But the 'willRotateToInterfaceOrientation' event is never triggered, even as i change the orientation. Thus the orientation specific image is not updated.
Any pointers to what am doin wrong?
Or is there any other way of doing this?
Thanks in Advance!