I’m trying to add a view to my controller, which is put into landscape mode programmatically with the follwoing code:
- (void)viewDidLoad {
[super viewDidLoad];
//EpisodeView *nextEpisode = [self getNextEpisode];
UIImageView *nextEpisode = [[UIImageView alloc] initWithImage:[UIImage imageNamed: @"default-background.png"]];
CGRect selfBounds = self.view.bounds;
nextEpisode.frame = selfBounds;
[self.view addSubview:nextEpisode];
}
The problem is that the added view draws itself in portrait mode, not in landscape. Can anyone please point out what I could have missed?
When I’m adding the same view using Interface Builder, all works perfectly fine. So, I think, I have missed some property or something like that.
You probably haven’t added
autoresizingMaskswhich are by defaultUIViewAutoresizingNone. IB has different defaults. Set them as needed.