Extend UIWebView to handle all special links

Thursday, October 29th, 2009 Share on Twitter

Have you ever wanted to add an UIWebView to your application, so you can browse the internets without leaving your application? While it is a trivial task to add an UIWebView to a project, there are some links that an UIWebView will not handle. These are: mailto YouTube maps.google.com iTunes AppStore I've written a generic BrowserViewController, code ...

Designing an iPhone Application: tools round up

Thursday, September 24th, 2009 Share on Twitter

There are different schools on how to start the design of an iPhone app. Some will prefer designing on paper (I do), others will use the computer to design their next breath-taking GUI. So here is a list of some of the tools, template to design your next iPhone application. Templates: Keynote '09: ...

Arbitrary rotation of a CGImage

Friday, September 4th, 2009 Share on Twitter

For my current project, I have to rotate a CGImageRef by an arbitrary angle. Here is the code: - (CGImageRef)CGImageRotatedByAngle:(CGImageRef)imgRef angle:(CGFloat)angle { CGFloat angleInRadians = angle * (M_PI / 180); CGFloat width = CGImageGetWidth(imgRef); CGFloat height = CGImageGetHeight(imgRef); CGRect imgRect = CGRectMake(0, 0, width, height); ...

Apple Push Notification Service Gateways

Friday, August 7th, 2009 Share on Twitter

I've not yet had the request to implement Push in an iPhone app, but a thread on the Developer Forums gave me a hint: Some companies are already providing (or planning to provide) a gateway to the APN: These are: Urban Airship iLime AppNotify These are in closed beta: Push.io iPushServer.com msgpush Urban Airship and iLime also provide In App ...

Reading the battery level programmatically

Saturday, February 14th, 2009 Share on Twitter

A beta-tester was complaining the application was draining its battery. To check if this was really the case, I needed to get the battery level with a better accuracy than just looking at the battery icon. So I used this little routine to check. This routine is adapted from a post ...

Redirect NSLog to a file on the iPhone

Friday, January 9th, 2009 Share on Twitter

If you need to debug your app when disconnected from your Mac (and from the console), redirect all your NSLog calls to a file so you can later read it. The method below will create a file name "console.log" in the Documents folder of your application so you can later read ...

Macros for Xcode

Monday, January 5th, 2009 Share on Twitter

These are some of the macros I use with Xcode: CMLog: I use this macro to replace NSLog: #define CMLog(format, ...) NSLog(@"%s:%@", __PRETTY_FUNCTION__,[NSString stringWithFormat:format, ## __VA_ARGS__]); When you use this macro, it outputs text to the console, including the class and method from where it was called. So, if you call this macro ...

HowTo fit text inside a UIWebView

Monday, January 5th, 2009 Share on Twitter

If, like me, you want to make sure your text will fit inside your UIWebView (without scrolling), you can implement the following javascript: <script language='javascript' type="text/javascript"> function adjustHeight(maxHeight) { elem = document.getElementById("sign"); height = ...

Add an UIProgressView or UIActivityIndicatorView to your UIAlertView

Sunday, November 9th, 2008 Share on Twitter

This snippet shows how to add an UIProgressView to an UIAlertView. You can choose to display an UIProgressView or an UIActivityIndicatorView in the alert. This may break with a new version of the SDK (2.1 for now), but this was accepted by Apple (or they didnt see it) - (void) createProgressionAlertWithMessage:(NSString *)message withActivity:(BOOL)activity { ...

Finally

Friday, November 7th, 2008 Share on Twitter

After 14713 lines of code, here is my first iPhone application: iVault, available in the AppStore.