1. <tfoot id='MCNVc'></tfoot>
        <bdo id='MCNVc'></bdo><ul id='MCNVc'></ul>

    2. <small id='MCNVc'></small><noframes id='MCNVc'>

    3. <i id='MCNVc'><tr id='MCNVc'><dt id='MCNVc'><q id='MCNVc'><span id='MCNVc'><b id='MCNVc'><form id='MCNVc'><ins id='MCNVc'></ins><ul id='MCNVc'></ul><sub id='MCNVc'></sub></form><legend id='MCNVc'></legend><bdo id='MCNVc'><pre id='MCNVc'><center id='MCNVc'></center></pre></bdo></b><th id='MCNVc'></th></span></q></dt></tr></i><div id='MCNVc'><tfoot id='MCNVc'></tfoot><dl id='MCNVc'><fieldset id='MCNVc'></fieldset></dl></div>

        <legend id='MCNVc'><style id='MCNVc'><dir id='MCNVc'><q id='MCNVc'></q></dir></style></legend>
      1. IOS:用标签值改变 UIImageView

        时间:2023-09-10
          1. <small id='mxTce'></small><noframes id='mxTce'>

              <bdo id='mxTce'></bdo><ul id='mxTce'></ul>
              <i id='mxTce'><tr id='mxTce'><dt id='mxTce'><q id='mxTce'><span id='mxTce'><b id='mxTce'><form id='mxTce'><ins id='mxTce'></ins><ul id='mxTce'></ul><sub id='mxTce'></sub></form><legend id='mxTce'></legend><bdo id='mxTce'><pre id='mxTce'><center id='mxTce'></center></pre></bdo></b><th id='mxTce'></th></span></q></dt></tr></i><div id='mxTce'><tfoot id='mxTce'></tfoot><dl id='mxTce'><fieldset id='mxTce'></fieldset></dl></div>

                <legend id='mxTce'><style id='mxTce'><dir id='mxTce'><q id='mxTce'></q></dir></style></legend>

                  <tbody id='mxTce'></tbody>
                <tfoot id='mxTce'></tfoot>
                • 本文介绍了IOS:用标签值改变 UIImageView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有 20 个 UIImageView,我想更改它们的图像;但我不想创建 20 个 IBOutlet,我想使用标签值来更改图像;我在界面生成器和之后设置标签值?如果我想在 Imageview 15 号更改图像?我该怎么办?

                  I have 20 UIImageView and i want change their image; but I don't want to create 20 IBOutlet, and I want to use tag value to change the image; I set the tag value in interface builder and after? If I want to change image at Imageview number 15? How can I do?

                  推荐答案

                  如果你使用标签,你可以像这样识别你的标签视图(UIImageView 是 UIView 的子类,具有标签属性):

                  If you use tags you can identify your tagged view (UIImageView is a subclass of UIView, which has the tag attribute) like this:

                  - (UIView *)viewWithTag:(NSInteger)tag
                  

                  因此,如果您在您的超级视图(所有 UIImageView 都驻留在其中)上调用此方法,您应该这样做:

                  So if you call this method on your superview (which all the UIImageViews reside in), you should do it like this:

                  UIImageView *myImageView = (UIImageView *)[myAwesomeSuperview viewWithTag:15];
                  

                  (文档 我使用 Google 找到的).

                  (Documentation I found using Google).

                  P.S:如果您认为添加 20 个 IBOutlets 工作量太大,我建议您也以编程方式创建 UIImageViews.这样你就完全不需要 xib 文件了,只需要编写一小段代码,就能事半功倍.

                  P.S: if you think it is too much work to add 20 IBOutlets, I recommend you create the UIImageViews programmatically as well. This way you will not need a xib file at all, write a small piece of code and have better maintenance with less effort.

                  这篇关于IOS:用标签值改变 UIImageView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Xcode 使用 FIXME、TODO、???,? 下一篇:Android:如何使 NFC 标签只为用户准备好并且对我可写?

                  相关文章

                    <bdo id='SFTKg'></bdo><ul id='SFTKg'></ul>

                    <small id='SFTKg'></small><noframes id='SFTKg'>

                    <tfoot id='SFTKg'></tfoot>
                    <i id='SFTKg'><tr id='SFTKg'><dt id='SFTKg'><q id='SFTKg'><span id='SFTKg'><b id='SFTKg'><form id='SFTKg'><ins id='SFTKg'></ins><ul id='SFTKg'></ul><sub id='SFTKg'></sub></form><legend id='SFTKg'></legend><bdo id='SFTKg'><pre id='SFTKg'><center id='SFTKg'></center></pre></bdo></b><th id='SFTKg'></th></span></q></dt></tr></i><div id='SFTKg'><tfoot id='SFTKg'></tfoot><dl id='SFTKg'><fieldset id='SFTKg'></fieldset></dl></div>

                      <legend id='SFTKg'><style id='SFTKg'><dir id='SFTKg'><q id='SFTKg'></q></dir></style></legend>