This post is about coming up with the idea that you will eventually turn into an iPhone application. Identifying a market and finding out what that market needs is essential to this process. The complimentary part of this is to know what the iPhone platform is capable of providing and executing on that. Here are [...]

Using Storyboards To Create A Single View Application
In my last post on Storyboards I talked in general about Storyboards with XCode and iOS. Now, it’s time for a nitty-gritty how to demonstration. How To Use Storyboards To Create An iOS App The simplest app that I can think of that would make use of iOS Storyboards is a single scene app that [...]

How To Design A Custom UITableViewCell From Scratch
In this tutorial, our guest blogger Tope will be showing you how to design a Table View with custom cells. Why would you want to do this, you ask? Well, sometimes the default list view from Apple just doesn’t cut it anymore. Having a nice, custom design is a good way to give your app [...]
UIButton Tutorial
iPhone apps use buttons to let users signal intentions to our iOS app. UIKit has a special class called UIButton, a subclass of UIControl, that gives us an easy way to add buttons to our app. Let’s talk about how you would add a button to your app. Adding UIButtons To iOS Apps First, let’s [...]
Core Location Tutorial
One of the coolest features of iOS is the ability for us as developers to use the location of our user’s iPhone in space in our apps. Core Location is the framework that gives us the ability to do this. How Core Location Finds Us We only need to put a few lines of [...]
How to Make a Toolbar with UIToolbar
Toolbars are used to present a set of functions to a user. You will see these at the bottom of iPhone apps and generally give you the option to do things like edit files, send email or take a picture. Here is an example of what a toolbar will look like in an iPhone app:

Using UIToolbar in Your iPhone Apps
Today, I am going to show you how to use UIToolbar in your iPhone apps. Essentially, what you need to do is to create an instance of UIToolbar, add buttons to it and then add the toolbar to your view. Usually, you will also need to assign actions to each toolbar button as well.
Here is video of how to use UIToolbar taken from my own code library that I ship with my ebook:
Source Code for Using UIToolbar
#import "Toolbar.h"
@implementation Toolbar
UILabel *label;
UIToolbar *toolbar;
- (void)viewDidLoad {
[super viewDidLoad];
//Create label
label = [[UILabel alloc] init];
label.frame = CGRectMake(10, 10, 300, 40);
label.textAlignment = UITextAlignmentCenter;
label.text = @"Press Button";
[self.view addSubview:label];
[label release];
//create toolbar using new
toolbar = [UIToolbar new];
toolbar.barStyle = UIBarStyleDefault;
[toolbar sizeToFit];
toolbar.frame = CGRectMake(0, 410, 320, 50);
//Add buttons
UIBarButtonItem *systemItem1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
target:self
action:@selector(pressButton1:)];
UIBarButtonItem *systemItem2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
target:self
action:@selector(pressButton2:)];
UIBarButtonItem *systemItem3 = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemCamera
target:self action:@selector(pressButton3:)];
//Use this to put space in between your toolbox buttons
UIBarButtonItem *flexItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil
action:nil];
//Add buttons to the array
NSArray *items = [NSArray arrayWithObjects: systemItem1, flexItem, systemItem2, flexItem, systemItem3, nil];
//release buttons
[systemItem1 release];
[systemItem2 release];
[systemItem3 release];
[flexItem release];
//add array of buttons to toolbar
[toolbar setItems:items animated:NO];
[self.view addSubview:toolbar];
}
//Action methods for toolbar buttons:
- (void) pressButton1:(id)sender{
label.text = @"Add";
}
- (void) pressButton2:(id)sender{
label.text = @"Take Action";
}
- (void) pressButton3:(id)sender{
label.text = @"Camera";
}
- (void)dealloc {
[toolbar release];
[label release];
[super dealloc];
}
@end
What Functions Do You Think Fit In Well On a Toolbar?
Discuss in the comments below!
CodeProject
|
If you are completely new to iPhone programming and want to start to developing iPhone apps this ebook will give you everything you need to get started today.
You Get the 5 Essential Things You Need to Make iPhone Apps
|
This ebook is much different than the other books out there: it really is a *system* that includes ONLY what you need to know to make iPhone applications. Not only that, but you will get some real insight on how to make a product and how to set up your code in the best way the first time.
Plus, you will get plenty of bonuses including exclusive source code projects. For more information, head on over to the website for the ebook:
Head over to How To Make An iPhone App eBook Website website to find out how to get Matt’s eBook and the bonus source code.
Video Demo: How you get pictures into the iPhone Simulator
This was a problem I had early on – most of my apps required use of the camera or the photo library. For the longest time I believed that you couldn’t test the photo library on the simulator. I was wrong, it is actually pretty easy to get pictures into the simulator for testing. Here is a video demo of me doing just that:
Essentially, all you need to do is drag a picture file onto the Safari icon in the simulator and when it shows up click on it until you get a “Save Image” dialog. Press that button and presto – your image will be in the photo library.
Newsletter
Find Stuff
-
Everardo: Quick question on the last example with the swtich...
-
RRT: Thank you very much!...
-
MattjDrake: Hi Miguel, Thanks - what you see is what I have...
-
Miguel: Matt, These are great tutorials. Have you done...
-
Harold: Thanks for the tutorial, busy with my first non-ni...
-
How To Design A Custom UITableViewCell From Scratch
November 17, 2011
-
Using Blocks with Table Views
November 1, 2011
-
Using Storyboards To Make Navigation Based iPhone Apps
December 15, 2011
-
How to Make Your iPhone App Send Email with Attachments
July 14, 2009
-
How to Play a Short Sound in iPhone Code
August 17, 2009
-
Our iPhone Training Sneak Peak!
May 8, 2012
-
iPhone Training
May 2, 2012
-
How to Archive Your Object Graph
April 26, 2012
-
Here’s Your Free iMAM iOS SDK Training Module
April 19, 2012
-
Some Crazy New Updates to iMAM
April 13, 2012
Topics
About Matt
In 2008 I left my cubicle to make iPhone apps full time and now I want to help you!





