在 iPhone 屏幕上显示 NSArray 中的索引 png 文件
我喜欢在iPhone上创建一个艺术品柜台显示器,显示0到9。这10位数字是10个png-文件,其中数字0到9作为其艺术品内容。这10个png-文件是使用NSArray实现的。下面你会找到实现代码:
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];
作为 10 位数字的索引,我使用一个整数变量,用 0 初始化:
int counter = 0;
此外,我以编程方式声明一个 UIImageview:
UIImageView *zahlenEinsBisNeun;
UIImageview 的实现代码是:
zahlenEinsBisNeun = [UIImage alloc] initWithFrame:CGRectMake(240, 50, 200, 200)];
????????????????????????????????????????
[self.view addSubview:zahlenEinsBisNeun];
[zahlenEinsBisNeun release];
在那里,你看到问号,我不知道如何编写代码,使用索引“计数器”从 NSArray 检索我的内容艺术品 0 到 9,并使用 ....addSubview:zahlenEinsBisNeun ...使其在我的 iphone 屏幕上可见...
任何人都可以帮忙吗???
感谢您提前提供的支持
Thomas Hülsmann
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
首先,而不是
zahlenEinsBisNeun = [UIImage alloc] initWithFrame:CGRectMake(240, 50, 200, 200)];
那么
......
你需要在此之前调整每个图像的帧
first of all instead of
zahlenEinsBisNeun = [UIImage alloc] initWithFrame:CGRectMake(240, 50, 200, 200)];
write
then
you'll need to adjust frame of each image before this...
我不太熟悉 iPhone SDK/图像属性,但你肯定只是
返回你想要的 UI 图像吗?
I'm not to familiar with the iPhone SDK/image properties but surely you'd just
to return the UI image you want?
我不确定我是否理解你的问题,但我认为你应该只添加一个 UIImageView 到子视图,并从 UIImageView
和计时器或任何线程(在其他函数中)更改 IMAGE 字段,如果你想更改此 imageView 中的图像:
问候,
I'm not sure that i understand you problem, but i think you should add only one UIImageView to subview and change IMAGE field from UIImageView
and in timer or any thread (in other function) if you want change your images in this imageView:
regards,