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];
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.
Noun. subview (plural subviews) (computing, graphical user interface) A secondary or subsidiary view.
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.
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.
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];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With