【问题标题】:Access the dynamically loaded Labels in UIScrolView访问 UIScrollView 中动态加载的标签
【发布时间】:2011-02-02 09:00:36
【问题描述】:

我正在开发一个 iPhonne 应用程序,该应用程序要求我在特定操作上将 UILabel 动态添加到 UIScrollView,然后从同一视图中删除选定的标签。

我可以添加标签,但无法访问添加到删除的标签。删除标签后,其余标签应在视图中自动调整。

你能帮我解决这个问题吗?

提前谢谢!!.... :)

【问题讨论】:

    标签: iphone-sdk-3.0 dynamic uiscrollview uilabel


    【解决方案1】:

    当你添加 UILabel 时,你需要设置它的标签。例如

    [myLabel setTag:2]; //or set it to some dynamically produced integer
    

    然后当你想再次访问标签时

    UILabel *addedLabel = [myScrollView viewWithTag:2];
    

    然后你可以删除标签或做任何你通常做的事情

    不要使用 0 或 1 的标签,因为它们是默认值,您应该使用相同的标签查看视图。

    【讨论】:

      猜你喜欢
      • 2020-01-13
      • 1970-01-01
      • 1970-01-01
      • 2017-02-16
      • 1970-01-01
      • 1970-01-01
      • 2017-11-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多