Home Tutorial Iphone Examples UIView Access Subviews

 
 

Share on Google+Share on Google+
UIView Access Subviews
Posted on: September 22, 2010 at 12:00 AM
Advertisement
In the example, you'll learn how to create and access a subview on UIView.

UIView Access Subviews

In the example, you'll learn how to create and access a subview on UIView.

Syntax of adding subview at UIView.
- (void)addSubview:(UIView *)view;

Creating and accessing a subview : In the example we are creating & adding a UIImageView on the UIView as a subview programatically. The method can be written into the "viewDidLoad" method that do the additional setup after the loading view.

a simple example:

- (void)viewDidLoad {
[super viewDidLoad];

UIImage *one = [UIImage imageNamed:@"imagename.png"];
UIImage *two = [UIImage imageNamed:@"Krishna_Arjuna.png"];

//Creating a subview
UIImageView *imageView1 = [[[UIImageView alloc] initWithImage:one] autorelease];
UIImageView *imageView2 = [[[UIImageView alloc] initWithImage:two] autorelease];

imageView2.alpha = 0;

//Adding subview
[self.view addSubview:imageView1];
[self.view addSubview:imageView2];

}

Download Code

Advertisement

Related Tags for UIView Access Subviews:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: September 22, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com