【问题标题】:get UIImageView under another UIImageView获取另一个UIImageView下的UIImageView
【发布时间】:2014-07-18 10:11:44
【问题描述】:

我有一些问题。

我在 self.view 上添加了 UIImageView。比添加了另一个 UIImageView。第二个 UIImageView 可以在 self.view 上移动。

当第二个 UIImageView 超过第一个 UIImageView 时,我可以获得第一个 UIImageView 的标签吗?

谢谢

【问题讨论】:

  • 不清楚,但先尝试将标签设置为uiimageview,然后尝试获取标签。设置标签:-firstimageview.tag=1;获取标签:- int tag=firstimageviiew.tag;
  • 是的,我设置了标签。只需要知道如何判断另一个 UIImageView 下的 UIImageView 是什么。

标签: ios objective-c uiimageview tags


【解决方案1】:
First give tag to firstimageview and secondimageview then using that tag you can identify any image view using below code
 UIImageView *firstimgeview = (UIImageView*)[self.view viewWithTag:firstimageviewtag];
 UIImageView *secondimgeview = (UIImageView*)[self.view viewWithTag:secondimageviewtag];

【讨论】:

  • 是的,但我必须比较 firtimgeview 和 secondimgeview 的坐标?如果他们 equils,而不是 secondimgeview 下的 firstimgeview,是吗?
  • 是的,你是对的,你也可以通过比较两个图像视图的中心来获得,如果两个图像视图中心相等,那么两者都是重叠
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多