Jason George
Jason George

Reputation: 7012

Problems with Programmatically Adding UIImageView on iPhone

I'm trying to programmatically add dots to a radar screen. The code runs without complaint, but I can't seem to get the dots to show up on screen. I do have a background UIImageView that covers the entire screen, but based on the documentation I expect my new UIImageView to be added to the front (not to mention I've tried bringSubViewToFront:).

Since I'm not sure how to go about debugging this, if someone could show me where I went wrong that would be great.

UIImage *dot;
CGRect dotFrame;
UIImageView *dotView;

// loop through enemies, dropping pins
dot = [UIImage imageNamed:@"enemyDot.png"];
dotFrame = CGRectMake(0, 0, dot.size.width, dot.size.height);
for(location in enemyAgents){

  // add the dot
  dotView = [[UIImageView alloc] initWithFrame:dotFrame];
  dotView.center = CGPointMake(100, 100);
  [self.view addSubview:dotView];
  [dotView release];
  dotView = nil;
}

Upvotes: 0

Views: 3301

Answers (1)

nevan king
nevan king

Reputation: 113777

Do you need to add dot to your dotView? Something like:

dotView.image = dot

Upvotes: 2

Related Questions