Creating your first iOS app by A-Nony-Mus
Featured

Step 6: Have some fun by adding things programmatically

To make it a little more advanced, we are going to add everything programmatically.

1. Delete the label we added to the UI as well as all the code we wrote up to this point.

2. Open ViewController.h and add the Following code between the @interface ViewController: UIViewController and @end:
@property (strong, nonatomic)UILabel *label;
Notice how a circle did not appear this time? That's an indication that you did it correctly

3. In ViewController.m add @synthesize label; right beneath @implementation ViewController and add [self setLabel:nil]; in the viewDidUnload function.

4. In the viewDidLoad function add the following lines of code:
//Define where the label will be displayed
self.label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 100)];
//Define the text to be displayed
self.label.text = @"Hello World";
//Center the Text
self.label.textAlignment = UITextAlignmentCenter;
//Programmatically add the label to the view
[self.view addSubview:self.label];

5. Hit run and admire your handiwork, you've completed your first iOS application
 
Remove these adsRemove these ads by Signing Up
carlmal says: Aug 20, 2012. 7:28 AM
Would be great if you could include how to get the app onto your device. Thanks for the instructable.
A-Nony-Mus (author) says: Aug 20, 2012. 9:00 AM
Unfortunately (and I learned this the hard way), you need to be a part of the paid developer program (US $100/year) in order to put the app on your device.
MHaakansson says: Aug 22, 2012. 12:55 AM
For your own device, connected with your iTunes, you don't need to be in the developer program - just connect the device for sync.
But if you want your app in the AppStore, you need to be in the program.
best regards
Martin
Zaphod Beetlebrox says: Sep 15, 2012. 6:36 AM
Is it jailbroken?
A-Nony-Mus (author) says: Aug 22, 2012. 3:22 PM
I had to join the program to put it on my device, but if you'd post an 'ible on how to do that, I'd love to be proven wrong.
hojijoon says: Aug 22, 2012. 7:45 AM
very nice thank you bro!
zacker says: Aug 20, 2012. 5:22 AM
all that just to say Hello World? whats it take to make an actual app like these photo editing apps and such?
A-Nony-Mus (author) says: Aug 20, 2012. 9:06 AM
Apple has tons of sample code if you want to take a look at that and get the idea of the size of an average program.
remendab says: Aug 20, 2012. 6:11 AM
That is not all that much work - really. With much power comes much responsibility, meaning that there are many small things required just to get up and running, but once you are, running that is, the next steps are not that much more complex
zacker says: Aug 20, 2012. 7:09 AM
...like baby steps.. lol Thanks!
jschmukendorf says: Aug 19, 2012. 6:54 PM
Very nice introduction to writing an app! This could be the road to riches for someone with a good idea an a willingness to learn.

Thank you!!
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!