How to programmatically set images in iOS @techytube
How to programmatically set images in iOS  @techytube
Uploaded November 2012 | Updated September 2026, 2 weeks ago
Subscribe to our channel here for notifications on new video trainings. For more videos on technology, visit our website at http://www.techytube.com.
By pavel@techytube, for more from this author visit:
techytube.com/author/pavel

The UIImageView class provides a view-based container for displaying images on iOS devices screens.
Most of the times we will set images for our UI controls visually, using the Xcode integrated Interface Builder.
But there may as well situations when we need to do that programmatically (probably we need to dynamically set images depending on different flags or situations). In those cases we first have to created the object that will contain the image:
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 200, 100, 100)];
Than we must set the actual image, by using the "image" property in case of UIImageView objects:
imageView.image = [UIImage imageNamed:@"testImage"];
And finally add that UI object to the main view:
[self.view addSubview:imageView];
iOS will take care of all the details, and will correctly load the corresponding image for the specific device.
Note that is now necessary to specify the .png or some other extension for the image. However, you can do that if you want, and you'll get the same results.

For more details, please visit Apple's Online Documentation at:

developer.apple.com/library/ios/#documentation/uikit/reference/UIImageView_Class/Reference/Reference.html
How to programmatically set images in iOS.NET 2.0/Winforms Multithreading with GUI ElementsWindows 8 Development - C# IntroductionWindows 8 Development - Javascript Split ControlRPM (Redhat Package Manager) Part 3 of 3Windows 8 Development - Javascript Event HandlersWindows 8 Development - Javascript XmlHttpRequestWindows 8 Development - Installing Visual StudioASP.NET - Razor Model DirectiveSonicWall Address and Service ObjectsWorking with Report Builder 3.0Working with UITableView objects in iOS
techytube |

How to programmatically set images in iOS

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER