Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/44.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何获取UIView的access子视图?_Iphone_Uiview_Subview - Fatal编程技术网

Iphone 如何获取UIView的access子视图?

Iphone 如何获取UIView的access子视图?,iphone,uiview,subview,Iphone,Uiview,Subview,如果要访问imageView1和imageView2,请根据此代码 我怎样才能访问它? 请给我举个例子 示例cell.accessoryView.subview UIImageView *imageView1 = [[[UIImageView alloc] init] autorelease]; UIImageView *imageView2 = [[[UIImageView alloc] init] autorelease]; imageView2.alpha = 0; [cell.acces

如果要访问imageView1和imageView2,请根据此代码 我怎样才能访问它? 请给我举个例子

示例cell.accessoryView.subview

UIImageView *imageView1 = [[[UIImageView alloc] init] autorelease];
UIImageView *imageView2 = [[[UIImageView alloc] init] autorelease];
imageView2.alpha = 0;
[cell.accessoryView addSubview:imageView1];
[cell.accessoryView addSubview:imageView2];

可以使用视图的标记属性:

UIImageView *imageView1 = [[[UIImageView alloc] init] autorelease];
imageView1.tag = 100;
UIImageView *imageView2 = [[[UIImageView alloc] init] autorelease];
imageView2.tag = 200;
imageView2.alpha = 0;
[cell.accessoryView addSubview:imageView1];
[cell.accessoryView addSubview:imageView2];
然后使用
-viewWithTag:
方法获取子视图:

UIImageView *getImageView1 = (UIImageView*)[cell.accessoryView viewWithTag:100];

我相信您只需调用
[cell.accessoryView子视图]