0

i like to create an artwork counter- display on an iphone, diplaying 0 to 9. The 10 digits are 10 png- files with the numbers 0 to 9 as their artwork content. The 10 png- files are implemented by using NSArray. Following you'll find the implementation- code:

zahlenArray = [NSArray arrayWithObjects:
           [UIImage imageNamed:@"ziffer-0.png"],
           [UIImage imageNamed:@"ziffer-1.png"],
           [UIImage imageNamed:@"ziffer-2.png"],
           [UIImage imageNamed:@"ziffer-3.png"],
           [UIImage imageNamed:@"ziffer-4.png"],
           [UIImage imageNamed:@"ziffer-5.png"],
           [UIImage imageNamed:@"ziffer-6.png"],
           [UIImage imageNamed:@"ziffer-7.png"],
           [UIImage imageNamed:@"ziffer-8.png"],
           [UIImage imageNamed:@"ziffer-9.png"],               
           nil];

As an index for the 10 digitis I use an integer variable, initializing with 0:

int counter = 0;

Furthermore I declare an UIImageview programmaticaly:

UIImageView *zahlenEinsBisNeun;

The implementation code for the UIImageview is:

zahlenEinsBisNeun = [UIImage alloc] initWithFrame:CGRectMake(240, 50, 200, 200)];

????????????????????????????????????????

[self.view addSubview:zahlenEinsBisNeun];
[zahlenEinsBisNeun release];

There, where you see the questionmarks, I don't know how to write the code, to retrieve my content artworks 0 to 9 from NSArray with the index "counter" and make it visible on my iphone screen by using .... addSubview:zahlenEinsBisNeun ...

Can anybody help???

My thanks for your support in advance

Thomas Hülsmann

4

3 回答 3

1

首先而不是zahlenEinsBisNeun = [UIImage alloc] initWithFrame:CGRectMake(240, 50, 200, 200)];

zahlenEinsBisNeun = [UIImageView alloc] initWithFrame:CGRectMake(240, 50, 200, 200)];

然后

for(int i = 0; i < 10 ; i++)
{
      UIImage *tempImage = [zahlenArray objectAtIndex:i];
      [zahlenEinsBisNeun addSubview:tempImage];
}
[self.view addSubview:zahlenEinsBisNeun];
[zahlenEinsBisNeun release];

在此之前,您需要调整每个图像的帧...

于 2010-03-27T12:07:07.750 回答
0

我不熟悉 iPhone SDK/图像属性,但你肯定只是

[zahlenArray objectAtIndex:counter]

返回您想要的 UI 图像?

于 2010-03-27T11:56:45.003 回答
0

我不确定我是否理解您的问题,但我认为您应该只向子视图添加一个 UIImageView 并从 UIImageView 更改 IMAGE 字段

[self.view addSubview:zahlenEinsBisNeun];

如果您想更改此 imageView 中的图像,请在计时器或任何线程(在其他函数中):

zahlenEinsBisNeun.image = [zahlenArray objectAtIndex:counter]

问候,

于 2010-06-13T16:00:15.933 回答