使用-viewWithTag时返回什么UIView:当几个视图具有相同的.tag? [英] What UIView is returned when using -viewWithTag: when several views have same .tag?

查看:138
本文介绍了使用-viewWithTag时返回什么UIView:当几个视图具有相同的.tag?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有4个UIViews,在IB中制作,所有标签属性= 2

Say I have 4 UIViews, made in IB, all with the tag property = 2

当我得到一个视图:

 UIView *thisView = (UIView*)[self.view viewWithTag:2];

检索UIView的标准是什么,因为有几个具有相同的.tag值?

What is the criterion for retrieving that UIView since several have the same .tag value?

是吗:


  • random

  • 第一个一个创建

  • 其超级视图中索引最低的视图

  • 其他

  • random
  • the first one created
  • the view with the lowest index in it's superview
  • something else

推荐答案

它很奇怪但是如果你尝试在具有相同标签的视图中获取视图,则会返回首先添加的视图。您也可以这样检查。

Its weird but the view that is added first will be returned if you try to get the views among the views with same tag. You can check it in this way too.

NSLog(@"%@",[[self.view viewWithTag:custTag] class]);

希望这会有所帮助。

这篇关于使用-viewWithTag时返回什么UIView:当几个视图具有相同的.tag?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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