Uploaded October 2012 | Updated September 2026, 1 week 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
You use the UISwitch class to create and manage the On/Off buttons you see, for example, in the preferences (Settings) for such services as Airplane Mode. These objects are known as switches.
The UISwitch class declares a property and a method to control its on/off state. When the user manipulates the switch control ("flips" it) a UIControlEventValueChanged event is generated, which results in the control (if properly configured) sending an action message.
You can customize the appearance of the switch by changing the color used to tint the switch when it is in the on position.
In iOS 5 and iOS 6 you can set some properties that gives you even more possibilities of customisation.
For more, you can visit the Apple's Online Documentation at:
developer.apple.com/library/ios/#documentation/uikit/reference/UISwitch_Class/Reference/Reference.html
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
You use the UISwitch class to create and manage the On/Off buttons you see, for example, in the preferences (Settings) for such services as Airplane Mode. These objects are known as switches.
The UISwitch class declares a property and a method to control its on/off state. When the user manipulates the switch control ("flips" it) a UIControlEventValueChanged event is generated, which results in the control (if properly configured) sending an action message.
You can customize the appearance of the switch by changing the color used to tint the switch when it is in the on position.
In iOS 5 and iOS 6 you can set some properties that gives you even more possibilities of customisation.
For more, you can visit the Apple's Online Documentation at:
developer.apple.com/library/ios/#documentation/uikit/reference/UISwitch_Class/Reference/Reference.html
![Working with paths and urls in Objective-C
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:
http://www.techytube.com/author/pavel
When working with files in Objective-C, we can specify the paths to them as follows:
NSString *path = @/Users/pavel/file.txt;
However, the recommended way (by Apple engineers) to specify that is by using URL-s (Uniform Resource Locator).
The iOS SDK class that provides us urls manipulation is named NSURL, and it has a lot of class convenience methods that make developers lives easier.
To create a NSURL object, we use the syntax:
NSURL *url = [NSURL URLWithString:@file:///Users/pavel/file.txt];
Note that the way we specify the string is different from in path cases.
It should always have the file schema in front of it, than a colon, and 3 slashes.
If we want to create a NSURL object, providing a string as in path cases, we can use a NSURL method which allows us to do that:
NSURL *newUrl = [NSURL fileURLWithPath:@/Users/pavel/Public/file.txt];
To move files from one location to another using urls instead of paths, we should use:
[[NSFileManager defaultManager] moveItemAtURL:url toURL:newUrl error:nil]; Working with paths and urls in Objective-C](https://i.ytimg.com/vi/xix_7Nqa7qM/mqdefault.jpg)


![How to use the UIImageView class to animate a series of images
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:
http://www.techytube.com/author/pavel
An image view object provides a view-based container for displaying either a single image or for animating a series of images. For animating the images, the UIImageView class provides controls to set the duration and frequency of the animation. You can also start and stop the animation freely.
You specify the animation images by setting the animationImages property of the UIImageView object:
imageView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@blue],
[UIImage imageNamed:@green],
[UIImage imageNamed:@orange],
nil];
We specify the duration of the animation by setting the animationDuration property:
imageView.animationDuration = 3.0f;
We can start or stop animating the images by sending startAnimating or stopAnimating messages to the image view object:
[imageView startAnimating];
or
[imageView stopAnimating];
All images associated with a UIImageView object should use the same scale. If your application uses images with different scales, they may render incorrectly.
For more details, please visit Apples Online Documentation at:
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIImageView_Class/Reference/Reference.html How to use the UIImageView class to animate a series of images](https://i.ytimg.com/vi/yEbid5QUemY/mqdefault.jpg)

![How to create view controllers programmatically in iOS
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:
http://www.techytube.com/author/pavel
The UINavigationController class implements a specialized view controller that manages the navigation of hierarchical content. This class is not intended for subclassing. Instead, you use instances of it as-is in situations where you want your applications user interface to reflect the hierarchical nature of your content. This navigation interface makes it possible to present your data efficiently and also makes it easier for the user to navigate that content.
To create a navigation controller programmatically, you have to write the following code:
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
Usually that is done in the AppDelegate.m file, but it can be done in any file you need.
If you do that in the AppDelegate.m file than you should replace the line:
self.window.rootViewController = self.viewController;
with the following line:
self.window.rootViewController = navController;
and it is perfectly ok because UINavigationController is a subclass of UIViewController.
If you run the program, you may notice a blue navigation bar appears on the top. You can customise that if you want, or you can hide it using any of the 2 lines below:
navController.navigationBarHidden = YES;
navController.navigationBar.hidden = YES;
To set a title in the NavBar, you should write in the viewDidLoad method of the ViewController class that is currently displayed by the Navigator object, any of the 2 lines below:
self.navigationItem.title = @Title;
self.title = @Title; How to create view controllers programmatically in iOS](https://i.ytimg.com/vi/zDLjdxmdwxs/mqdefault.jpg)


