UIView的tag能帮助你寻找它的子视图。
比如你有一个UIView,这个UIView含有一个Button,而创建Button时用的是临时变量,你没有这个Button的引用,在这种情况下,你如果想访问这个UIView的Button,你就可以给这个Button一个Tag(必须唯一),需要用的时候就可以[UIView viewWithTag:]来取。
便于查找子视图,案例:
UILabel *label = [[UILabel alloc] init];
label.tag=123;
[self.view addSubview:label];
//不在同方法中使用时,可根据tag查找
UILabel *find_label = (UILabel *)[self.view viewWithTag:123];