开发者

Problems with Programmatically Adding UIImageView on iPhone

开发者 https://www.devze.com 2022-12-08 16:20 出处:网络
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 e

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 开发者_如何学Pythonme 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;
}


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

dotView.image = dot

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号