The TWG group has an outstanding set of iPhone icons suitable for tab bar item. Kudos to these guys for making this set of great icons available for the rest of us. You can use these icons in products. Here is the terms of use.
Archive for the ‘iPhone’ Category
Great free iPhone icons
April 3, 2010Adding your own colors to core-plot
March 29, 2010In HTML colors are typically specified in a HEX format, where each color is a number from 0 to 255 represented as a two digit hex number. For example, the aqua blue shade color is represented as 0095D2, where the value for Red is 00, the value for Green is 95 and the value of Blue is D2. For iPhone development, the colors are specified in RGB float where each of the RGB colors is a number between 0.0 to 1.0.
In core-plot, you can add your own colors via Objective-C category construct from within any of your own header and implementation files.
@interface CPColor (AQ_COLOR) +(CPColor *)aq_blue_color; // #0095D2 @end
@implementation CPColor (AQ_COLOR)
+(CPColor *) aq_blue_color {
static CPColor *color = nil;
if ( nil == color ) {
color = [[CPColor alloc] initWithComponentRed:(0x00&0xff)/255.0 green:(0x95&0xFF)/255.0 blue:(0xD2&0xFF)/255.0 alpha:1.0];
}
return color;
}
@end
Now you can use this color to fill a bar chart, e.g.
barPlot.fill = [CPFill fillWithColor:[CPColor aq_blue_color]];
Core-plot and iPhone
March 27, 2010Core-plot is a charting library for the Mac and iPhone. It is relatively easy to use and the resulting charts are not bad at all.
One issue that I ran across was that the iPhone application that I created to test core-plot worked fine on the Simulator but not on the iPhone where I would get a system exception resulting from the core-plot library calling sizeWithTextStyle method that was not linked in. To fix this issue, in Xcode right click on your application in the Targets group and select Get Info. Select the Build tab and enter “Other Linker Flags” in the search box. Make sure that you include the flags: -all_load -ObjC.
Here is an excellent tutorial on core-plot.
How to dismiss the keyboard in iPhone
May 27, 2009- In the Interface Builder add the text field to the view and use the inspector to change the Text Input Traits so that the Return Key is set to Done (see thumbnail).
- In the .h file for your view controller, define an IBAction method to dismiss the keyboard, e.g.
- (IBAction)dismissKeyboard:(id)sender;
- In the .m file define the method:
- (IBAction)dismissKeyboard:(id)sender { [sender resignFirstResponder]; } - In the Interface Builder, control click on the text field object, and connect the “Did End On Exit” event to the view controller’s File’s Owner object.
You can use the same method to dismiss the keyboard for all of the text fields in the view.
This technique no longer works in the latest version of IB (v3.2.1). Instead, you’ll need to connect the event “Did End of Exit” to the “First Responder” object in the “MainWindow.xib” and then select the “dismissKeyboard” method that you just introduced.
UIPickerView sample
May 20, 2009
UI to select a state from the picker to update the image/label. The arrow button controls the visibility of the picker.
Start Interface Builder and drag a Picker View object from the Library tool to the View object. This will create a UIPickerView object for you. Alternatively you can programmatically create this object in Xcode. But it is easier to use the IB. If you now build and run your project, you wont see the picker. To see it you’ll need to set the data source and delegate.
In IB, control-click on the Picker and then drag and connect the dataSource and delegate outlets to the File’s Owner for the view controller. Now if you build and run your application, you’ll see an empty picker. The control-click on the picker is a short cut for connecting the data source and the delegate properties. In addition, you’ll need to connect the picker to your view controller to create the object so that you can access it in Xcode. You do this by dragging the New Referencing Outlet from the IB’s Picker VIew Connection to the File’s Owner object in the xib file view. Alternatively, when you control-click, you can drag a New Referencing Outlet from the popup.
(more…)
Adding button and its handler in Objective-C using iPhone SDK
May 17, 2009In JavaScript, it is fairly easy to add a button and its event handlers. HTML and the browser are your Interface Builder and your text editor is your Xcode. There is no need to graphically connect anything and there is no confusion where you add the button and where you add the event handlers. For iPhone programming, the model is more sophisticated and hence it is more complicated to nail the basics. So how do you add a simple button and its event handler in Objective-C and iPhone SDK?
Typically you will want to add a button using the Interface Builder and then add the button’s event handlers in Xcode. Here are the steps:
- In Xcode double click on the NIB file that defines the view to which you wish to add a button. This will start the Interface Builder (IB).
- In IB, open the Library tool and drag a button to the view. Position and resize this button and give it a title.
- Now you need to connect the button to the View Controller class so that you can control and customize this button from Xcode. You can control-click on the button and drag the connection line to the File’s Owner in the xib view (alternatively, you can start the IB’s Inspector, select the Button Connection tab and create a Referencing Outlet – drag the connection similar to before).
- In Xcode you’ll need to define the button to the view controller’s interface file and then define the methods to customize the button and define its events handlers.
In this sample, I’ve added a UILabel and a UIButton class so that when you click on the button the value of the label is changed.
@interface TestViewController : UIViewController {
IBOutlet UILabel *mylabel;
IBOutlet UIButton *mybutton;
}
@property (nonatomic, retain) UILabel *mylabel;
@property (nonatomic, retain) UIButton *mybutton;
@end
In the implementation file, you need “synthesize” the label and button objects.
@implementation TestViewController @synthesize mylabel; @synthesize mybutton;
Next I try to customize the label on the button and add an event handler.
- (void)viewDidLoad {
[super viewDidLoad];
mylabel.text = @"www.aquacue.com";
[mybutton setTitle:@"Aquacue - Normal" forState: (UIControlState)UIControlStateNormal];
[mybutton setTitle:@"Aquacue - Highlighted" forState: (UIControlState)UIControlStateHighlighted];
[mybutton addTarget:self action:@selector(myButtonClick:) forControlEvents:(UIControlEvents)UIControlEventTouchDown];
}
Now here is the definition of the handler:
- (void)myButtonClick:(id)sender {
mylabel.text = @"Clicked";
}
Next I add another event handler so that when you click on the screen background, the value of the label is changed:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
mylabel.text = [NSString stringWithFormat: @"Hello Aquacue %@ %d", @"AAA", event.timestamp];
[super touchesBegan:touches withEvent:event];
}
You can also use the IB to define event handlers (aka Actions). The easiest way is to actually define the handler/action in Xcode using the IBAction declaration in the interface file (add the declaration just before the @end statement).
- (IBAction)myButtonPressed:(id)sender;
Next you’ll need to define the myButtonPressed handler in the implementation file:
- (IBAction)myButtonPressed:(id)sender {
mylabel.text = @"Change the label, when user clicks on the button";
}
Note that in this sample, I’ve defined two handlers one using the UIButton addTarget method and another using the IBAction. Both of these handlers are called when the user clicks on the button. As it turns it both of these handlers get called IBAction gets called first followed by the handler that was added via addTarget.
Only the methods defined with the IBAction declaration are exposed to the IB. You can control-click on the button object in IB and you’ll see a popup menu that defines all of the events that the object is willing to handle. Using the normal IB way, you’ll need to drag an event to the File’s Owner object to expose the event handler in Xcode.
Objective-C & string concatenation
May 17, 2009I’ve started learning objective-C for my iPhone SDK programming project and was wondering how to concatenate strings and integers, … I saw a number of posts on the web about how verbose Objective-C is compared to C#. No mention was made that C# arrived 20 years after Objective-C and it was a poorer version of Java. Anyhow, want to concatenate a bunch of primitive types as a string? Here is what you do (recall your sprintf syntax)
[NSString stringWithFormat: @"Hello Aqua %@ %d", @"cue ", 1];
For string concatenation, Objective-C is almost as concise as Perl -)
iZilch has been released!
April 8, 2009A former colleague of mine, Ken Anderson, recently started his iPhone app company (Crystal Springs Software, LLC) and just released a cool iPhone game called iZilch. Looks like this is going to be very popular. The UI is very clean and the controls are very intuitive. You can, for example, shake the phone to roll the dice.
Congratulations to Ken for getting the application released.
There is an informative video on the zilch site on how to use the game. It may be handy to include a link to this video with the instructions for the game on the iPhone itself.
MooCow Guitarist — keeps crashing
February 15, 2009MooCow Guitarist on iPhone can turn your iphone into a brick. I purchased the Guitarist a while back since I was intrigued with the idea of playing the guitar on an iPhone. Well initially it worked fine, but after a few upgrades of iPhone and the Guitarist software, it became highly unreliable. In my case it simply freezes the iPhone and after a few minutes it causes the iPhone to reboot. Sometimes it does start, but the sound is muted, and there is nothing you can do to un-mute it. I sent a couple of e-mails to the MooCow support, but never heard back from them. So if you want to get a guitar app for your iPhone, think twice before you waste your money on Guitarist.
iPhone contact list, me.com sync issues
January 17, 2009This afternoon, I got a call on my iPhone from an acquaintance who was already in my contact list and to my surprise the name of the person was not displayed on the iPhone just the number. I checked my address book and it had become empty. Thanks to the buggy Me.com sync operation, I’m sure. Well if this happens to you, before you start to panic, try this:
- Remove the me.com mail set-up from your iPhone
- Now add it back
This has happened to me twice, and in both cases, removing and adding the me.com mail account fixed the problem. Fortunately the sync didn’t delete all of my contacts on the me.com web site, just deleted all contacts on the iPhone.


