Ich muss abhängig von der UIInterfaceOrientation unterschiedliche Größe eines UIImage anzeigen. Jetzt ist das Problem, jedes Mal, wenn das Programm seine Ausrichtung ändert, ist das Bild immer noch da und das neue überlappt es. Hier ist, was ich habeUIView wird nicht entfernt
UIView *logoView;
UIImage *image = [UIImage imageNamed:@"pic.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
[logoView removeFromSuperview];
CGRect rect;
UIInterfaceOrientation newOrientation = [UIApplication sharedApplication].statusBarOrientation;
if(newOrientation == UIInterfaceOrientationLandscapeLeft || newOrientation == UIInterfaceOrientationLandscapeRight)
{
rect = CGRectMake(0, 0, self.view.bounds.size.width/2, self.view.bounds.size.height/4);
logoView = [[UIView alloc] initWithFrame:CGRectMake(0,0,self.view.bounds.size.width/2, self.view.bounds.size.height/4)];
}
else if (newOrientation == UIInterfaceOrientationPortrait || newOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
rect = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height/4);
logoView = [[UIView alloc] initWithFrame:CGRectMake(0,0,self.view.bounds.size.width, self.view.bounds.size.height/4)];
}
imageView.frame = logoView.bounds;
[logoView addSubview:imageView];
[self.view addSubview:logoView];