【问题标题】:Problem with creation of uiimageView in arrays在数组中创建 uiimageView 的问题
【发布时间】:2011-07-24 09:04:28
【问题描述】:

这是我的代码:

-(void) createImage {


UIImage * image = [UIImage imageNamed:@"abouffer_03.png"];
imageView = [[UIImageView alloc] initWithImage:image];

[imageView setCenter:[self randomPointSquare]];

 [imageViewArray addObject:imageView];

[[self view] addSubview:imageView];

[imageView release];


}

-(void)moveImage{
for(int i=0; i< [imageViewArray count];i++){
    UIImageView *imageView = [imageViewArray objectAtIndex:i];
    imageView.center = CGPointMake(imageView.center.x + X, imageView.center.y + Y);
}

我尝试在这段代码中使用数组,但它不起作用,事实上我从未使用过数组,如果有人能告诉我我的错误在哪里,那就太好了;谢谢。对不起我的英语我是法国人:/

【问题讨论】:

  • 您收到的错误是什么?
  • 没有报错,但是屏幕上没有“imageView”的图片
  • randomPointSquare 是如何实现的?可能它正在将图像视图置于屏幕之外。
  • 不,问题不是来自 randomPointSquare,因为它在没有我实现数组的情况下工作,问题必须来自数组
  • @bernard 你在哪里初始化数组?

标签: ios arrays xcode uiimageview


【解决方案1】:

你错过了: imageViewArray = [[NSMutableArray alloc]init];

【讨论】:

    猜你喜欢
    • 2023-03-17
    • 1970-01-01
    • 2020-09-20
    • 1970-01-01
    • 2012-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-26
    相关资源
    最近更新 更多