0

It's pretty embarrassing asking this because I've been building apps for a while now. In the past I've always used Interface Builder to set up my views etc.

Here is my loadView:

- (void)loadView {
    UIView *splashView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    splashView.backgroundColor = [UIColor clearColor];

    UIImageView *splashImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[[NSBundle mainBundle]pathForResource:@"splash" ofType:@"jpg"]]];
    splashImage.frame = [splashView bounds];
    [splashView addSubview:splashImage];

    self.view = splashView;
}

For some reason the imageView isn't appearing. No errors, but just no appearance. The UIView is added, but the UIImageView isn't.

Like I said, I've traditionally done this with IB so I'm not so familiar with the programatic method.

Any help appreciated.

Dan Hanly
  • 7,829
  • 13
  • 73
  • 134

2 Answers2

1

Add splashView to self.view:

self.view = splashView;

or add your splashImage into self.view. In this case you don't need the UIView - splashView:

UIImageView *splashImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[[NSBundle mainBundle]pathForResource:@"splash" ofType:@"jpg"]]];
splashImage.frame = [splashView bounds];
[self.view addSubview:splashImage];
CristiC
  • 22,068
  • 12
  • 57
  • 89
  • Sorry, that was a typo. I had the `self.view = splashView;` line but still no luck. I tried your other solution and I just get a black screen... Suggesting there's an issue with the image. I'll investigate – Dan Hanly Jun 21 '11 at 15:24
0

Try not creating a new view called splash view and just add the image view to your self.view.

StuStirling
  • 15,601
  • 23
  • 93
  • 150