iPhone - 如何从UILabels的集合中选择? [英] iPhone - how to select from a collection of UILabels?

查看:88
本文介绍了iPhone - 如何从UILabels的集合中选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个UILabels,其中任何一个将根据它们代表的NSArray索引的索引更新。我想通过他们的标签选择它们

I have a few UILabels, any one of which will update according to the index of an NSArray index they represent. I thought of selecting them by their tag

self.displayLabel.tag = myArray[index];

但将标签值更改为我目前持有的数据

but that changes the tag value to whatever my array is holding at the moment

使用字典提供的任何技巧,而不是一个NSArray没有帮助,因为我仍然必须选择正确的匹配标签。这是我想实现的效果。

Using a dictionary for whatever tricks it offers instead of an NSArray doesn't help because i still have to select the correct matching label. This is the effect i want to achieve.

self.|mySelectedLabel|.text = myArray[index];

我应该放什么| mySelectedLabel |找到我正在找的那个?

what should i put in |mySelectedLabel| to get the one i'm looking for?

我几乎感到羞于在我的声誉级别问,但是这阻碍了我
每个搜索只需转到如何设置标签和更改,而不是选择

I'm almost ashamed to ask at my reputation level, but this is stymie-ing me every search only turns up how to set Labels and change, not the process of selecting

推荐答案

假设您已将标记设置为相应的索引匹配你的
数组索引,你可以使用 [self.view viewWithTag:index] ;

Assuming you have set the tags to the appropriate index to match your array indices you can use [self.view viewWithTag:index];

这篇关于iPhone - 如何从UILabels的集合中选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆