Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get access subview of UIView?

according to this code if i want to access imageView1 and imageView2 how can i access to it? please show me some example

example cell.accessoryView.subviews ?

UIImageView *imageView1 = [[[UIImageView alloc] init] autorelease]; UIImageView *imageView2 = [[[UIImageView alloc] init] autorelease]; imageView2.alpha = 0; [cell.accessoryView addSubview:imageView1]; [cell.accessoryView addSubview:imageView2]; 
like image 543
RAGOpoR Avatar asked Mar 17 '10 09:03

RAGOpoR


People also ask

How do you check if a view contains a Subview?

If you need a quick way to get hold of a view inside a complicated view hierarchy, you're looking for viewWithTag() – give it the tag to find and a view to search from, and this method will search all subviews, and all sub-subviews, and so on, until it finds a view with the matching tag number.

What is a Subview?

Noun. subview (plural subviews) (computing, graphical user interface) A secondary or subsidiary view.

What is a Subview iOS?

Subview is childview which is added on any view. In iOS, UIView class is an object that manages the content for a rectangular area on the screen. UIView class contains the property var subviews: [UIView] Each view can contain multiple subviews of the same class UIView or its descendants.

What is UIView in Swift?

UIView can be defined as an object by using which we can create and manage the rectangular area on the screen. We can have any number of views inside a view to create a hierarchical structure of the UIViews.


1 Answers

You can use view's tag property:

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]; 

And later get subview using -viewWithTag: method:

UIImageView *getImageView1 = (UIImageView*)[cell.accessoryView viewWithTag:100]; 
like image 169
Vladimir Avatar answered Sep 21 '22 18:09

Vladimir