Writing a converter program for iPhone – Video tutorial

Writing a converter program for iPhone - Video tutorial

We continue to publish articles on programming for iOS in Objective-C. The second lesson will show you how to make a simple converter program for iPhone that converts temperatures from Forengate to Celsius and miles to kilometers.

Writing a converter program for iPhone - Video tutorial

Recall that in the first lesson we studied the UITextField element, which allows you to enter information into the program using the keyboard. This element is present in many applications and our converter will be no exception. Also, knowledge of the UILabel element, which will display the result of the program's work, will be useful to us.

Writing a converter program for iPhone - Video tutorial

interesting 6.1-inch iPhone 12 and iPhone 12 Pro go on sale first Epic Games asks court to return Fortnite to App Store

The logic of the program will be based on performing simple mathematical operations such as multiplication, division and subtraction. You will learn how to work with variables of a real type (floating point numbers) so that the result obtained is accurate, and not rounded to the nearest integer. I will also show you how to convert a variable from a numeric type to a text type (NSString) in order to display the result in a UILabel.

Writing a converter program for iPhone - Video tutorial

I will pay special attention to creating tabs using the TabBar Controller, with which you can split the application into several separate screens with the ability to quickly switch between them. The video demonstrates the process of creating such a control, as well as binding a unique icon to each created tab.

VIDEO

Below you can see the code that allows you to hide the virtual keyboard after entering information in the UITextField by clicking anywhere on the screen. This code needs to be inserted into the files DistViewController.m and TempViewController.m:

– (void) touchesBegan: (NSSet) touches withEvent: (UIEvent) event {for (UIView view in self.view.subviews) [view resignFirstResponder]; }

Download project sources
In order not to miss anything, subscribe to my YouTube channel.

Rate article
Mobile phones - news, reviews and life hacks.
Add a comment