Интересный код ...
Вы создаете объект UIImageView здесь:
if (!mainBackgroundImageView) {
mainBackgroundImageView=[[UIImageView alloc] init];
}
Нет никаких доказательств того, что это добавлено к представлению где-либо.Например:
[self.view addSubView:mainBackgroundImageView];
Кроме того, вы поддерживаете все повороты, поэтому просто верните yes здесь
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
Поместите работу здесь ...
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation duration:(NSTimeInterval)duration
{
if (interfaceOrientation==UIInterfaceOrientationPortrait || interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown)
{
mainBackgroundImageView.frame = portraitFrame; // set frame size here
[mainBackgroundImageView setImage:[UIImage imageNamed:@"dart-login-image.png"]];
} else {
mainBackgroundImageView.frame = landscapeFrame; // set frame size here
[mainBackgroundImageView setImage:[UIImage imageNamed:@"background-and-header-integerated.png"]];
}
}
Все это предполагает, что вы уже добавили mainBackgroundImageView к вашему представлению где-то как в - (void) viewDidLoad.
[self.view addSubView:mainBackgroundImageView];