Step 2: Create an object of UIImageView class in the .h file
@interface Myimageviewcontroller : UIViewController {
UIImageView *obj_imageView;
}
@end
Step 3: Go to the .m file and add the following piece of code.
[obj_imageView setFrame:CGRectMake(20, 47, 283, 312)];
obj_imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"AppleTV.jpg"]];
In the above piece of code i have set the frame of the UIImageView and i have loaded the imageview with a default image that i have took in the Resource folder of my project.
[For this code to work you must have an image present into your project].
Step 4: Go to the ImageDemoAppDelegate.m file and add the view to the window with the help of the given code
#import "ImageDemoAppDelegate.h"
#import "Myimageviewcontroller.h"
@implementation ImageDemoAppDelegate
@synthesize window;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
Myimageviewcontroller *objviewcontroller = [[Myimageviewcontroller alloc]init];
[window addSubview:objviewcontroller.view];
[window makeKeyAndVisible];
}
Step 5: Build and run the application you will get the below output on the iPhone simulator
Final Output |
i Hope this post was helpful for you, Happy iCoding
No comments:
Post a Comment