Monday, July 26, 2010

Application wide Fonts

So you get your nice shiny PSD's from the designer and your ready to tear though the new UI for your fantastic Application. However their is one problem. While the designs look great, the designer has chosen to use non default fonts. 

AFAIK there is no way to change the global default font for your app. So this means that have UILabel, and UITextField, and UITextView instance that you create needs to have it's font configured.

Configure each might take a while but what will take longer is if they decide to change their mind! While i'm relatively young, i've had this happened enough times that i know you should always plan for it.

so ....

This category provides you with some simply methods modelled on the existing UIFont class methods. Now if you couple this category with categories on the other text rendering classes, you have a nice short hand way to quickly render text in the font you want.



So as an example you could create a category on UILabel, and create a class method called labelWithAppSettings. This method would do the following
  1. Allocate and instantiate a UILabel
  2. Set it's font using one of the methods from UIFont+Additions
  3. Return a Autoreleased object
This would allow us to create (Outside of IB) UILabel's across our application with the default settings by calling [UILabel labelWithAppSettings].

Now if you want to use IB (and you should, cause it's awesome, seriously), you either swizzle or use a category to override the awakeFromNib  on the text rendering classes and set font there.

While the above is very cool, i generally dislike using swizzling, or overriding methods via categories in production code. This generally causes your fellow programmers to swear at you while your not there.

Happy Coding



Saturday, July 24, 2010

BBC News app, It's alrite

Now usually i don't blog about anything, but the BBC's new app provoked me. Fortunately not because it's bad but because it's really good.
Now what would make me stand up and take notice of this app. Well there are a couple of things.

Cross Platform design
I've never seen this grid like layout in a new app on the iPhone. While it works fairly well on this size device it really excels on the larger screen of the iPad. However the fact that both versions of the app share this is fantastic, and i think lends it's self well to the branding of the application.

UITableView
Well i first started making iPhone Apps i found the interface for the UITableViewDataSource annoying. Fast forward a couple of years and i love it. What amazes me even further is how versatile the UITableView class is. As far as i can tell that scrolling pane and it's content is all part of UITableView, with each row of cells being a custom UITableViewCell with a UIScrollView embedded within it, Pretty nifty if you ask me!

For all i know they could be using the mythical AQGridView, however i doubt this because of the nature of the "non-grid" content below the "fold".

Now because i'm the only iPhone developer in the world without an iPhone, i have performance issues on my iPod touch 2 gen. However while the app is a little slow i can still appreciate it.

In closing i think the folks at the beeb did a bang up job, well done

Thursday, July 22, 2010

Upgrade your iPhone Simulator to v4

If your building an app your pretty much guaranteed to have to use the iPhone Simulator. However in all the excitement it seems that Apple have forgotten to update the simulator graphics to reflect the fantastic new design.

So i had a little peak in to the iPhone Simulator.app bundle... and then i opened photoshop ... and i ended up with this



Initially the main take away, is that you can upgrade the appearance of your simulator to reflect the device of your choice, however realistically you could replace the image with anything you like.

Incase you want to do this for yourself, follow these steps

1. go to where you have installed xcode, usually /Developer
2. From there goto /Platforms/iPhoneSimulator.platform/Developer/Applications/
3. Control/Right click on the iPhone Simulator.app and select show package contents
4. Open and edit the frame.png image to your hearts content.

For the image above, i used the iOS4 UI mockup PSD from Geoff Teehan

Getting Annoyed so you don't have too

So your starting a new project, and you want to use some of the fantastic features of the three20 framework. Then you get hit with this

Ok, simple fix to this "there is no SDK with the name or path 'iphoneos3.0'" problem, you obviously forgot to set the SDK to iOS4 ... oh, but it's already set ...

Fortunately i'm here to save you some time and pain. What you actually need to do is navigate to the three20/src folder, and open each and every one of the three20 components and set project base SDK to iOS 4.0 and the deployment target to 3.0/3.1.

Once you do this to all the "dependencies", you should find that the project will compile and run just fine. There are few forks on github where peeps have done this for you, however i like to always pull from the main trunk where possible, so i'd rather do it myself.


Happy coding