Google Android Development Agency SASS
Showing posts with label iphone development. Show all posts
Showing posts with label iphone development. Show all posts

Friday, 8 May 2009

Changing the color of the iPhone navcontroller bar

You may have noticed some apps on the iPhone have different colored navigation bars. I didn't have any reason to play with this, but being an inquisitive iPhone developer I wanted to know how it's done. I hadn't even noticed that you could customise this in Interface Builder, but it turns out it's really simple.

Just open up your root view controller (MainWindow.xib) in interface builder. Now click on the NavController icon:



Now open up your inspector panel and look at the Top Bar drop down. You can select the color of the Nav Controller bar there, set it as either Normal (blue grey), Black or Translucent.



Now you can have a cool black nav controller too!

Wednesday, 6 May 2009

iPhone GPS programming is easy

Before I looked at GPS development for iPhone I was bracing myself for an onslaught of complicated hardware commands, old school C data structures and binary arithmetic. Queue a flashback to the CoreAudio learning curve...

Almost unbelievable it's not the case though; Apple have made things pretty straightforward for a change!

The first thing to do, and the key to it all, is to create a class which conforms to the CLLocationManagerDelegate specification:


@interface MyLocationManager : NSObject <CLLocationManagerDelegate> ...


The CLLocationManager delegate needs to contain a method which is called to notify it that the location has been updated. Basically, this:


- (void) locationManager:(CLLocationManager *) manager
didUpdateToLocation:(CLLocation *) newLocation
fromLocation:(CLLocation *) oldLocation {
...


Now within your method implementation you can access the coordinates of the old and new locations with:


newLocation.coordinate.latitude;
newLocation.coordinate.longitude;
newLocation.altitude;


Obviously you'll need to do a bit of jiggery pokery to get those raw figures into a useful state, but that's down to your own app logic. In terms of getting the GPS coordinates nothing could be easier!

Apple have a very good sample project in the developer library called LocateMe. I'd suggest you download it and study the code to learn the ins and outs of GPS programming. It took me literally 10 minutes to get the basics going.

Next stop - Android GPS development!