Blog posts
Flipping an image using objective-c is so easy once you know how...
//Create a normal image
UIImage* img = [UIImage imageNamed:@"myImage.png"];
//Flip it
UIImage* flippedImage = [UIImage imageWithCGImage:img.CGImage scale:1.0 orientation: UIImageOrientationDownMirrored];
That's it! Now to have it as an method we can use more conveniently, try this:
-(UIImage *)flipImage:(UIImage *)img {
UIImage* flippedImage = [UIImage imageWithCGImage:img.CGImage scale:1.0 orientation: UIImageOrientationDownMirrored];
return flippedImage;
}
Then we can send any image to it and it will return a flipped version.
Continue reading (permalink)
Posted in 'Programming'.
The uses of NSNotificationCenter can be many; It is handy for using to notify the app that a background download of data, a post of some kind is done, or some calculation is finished. It can also be useful for letting sub views know when some root level functions happen in the app such as shutdown/sending to background because the user tapped the home button. In this example I will be doing just that.
In the AppDelegate you should find a method named:
- (void)applicationDidEnterBackground:(UIApplication *)application
This is called when the app starts the process to pause into the background state. Since this method can only be called by the app delegate and not a sub view notifications are ideal for subviews so that they can do what they need such as save data or stop heavy processing of data.
//.m
- (void)applicationDidEnterBackground:(UIApplication *)application{
[[NSNotificationCenter defaultCenter] postNotificationName:@"UIApplicationDidEnterBackgroundNotification" object:self];
}
'UIApplicationDidEnterBackgroundNotification' is the name of the notification we send out. If we name notifications in a smart way it makes sense when you have lost of them to listen for.
In a sub view class we need tell it to listen (observe) for the 'UIApplicationDidEnterBackgroundNotification'. Add the notification observer to somewhere like the init so that it is listening as soon as the object is created. Lets go over the details before we see the code.
addObserver:self assigns the listener to the current object. We can also assign the listener to other objects, such as views, i.e: addObserver:myCustomViewControllerObject.
selector:@selector(theActionToCarryOut:) is which method to call when we get the notification.
name:@"UIApplicationDidEnterBackgroundNotification" is what notification we are listening to.
object:nil is which object sent it. By setting 'nil' we say that we don't care where the message came from. If we ...
Continue reading (permalink)
Posted in 'Programming'.
A few people have asked me recently “What are the good apps on an iPad”. So I have waded through all the apps I have bought, and come up with a list of the best, most fun and most useful that I have.
Consuming & Discovering
Pulse - $3.99
An RSS reader that is customisable with all your owen feeds or if you use google reader you can also subscribe to that. Pulse displays the feeds as a series of rows with the articles from each feed along them. Really easy to find some interesting stuff and especially good for content with lots of images.
Flipboard - FREE
Similar to Pulse but you can only choose from selected sources, which there are many, but not ideal for anyone with lots of random smaller news feeds. The layour is more magazine like with a contents section laying out all your subscribed feeds. The content is displayed as articles which makes it really nice to browse for stories. Also lets you subscribe to Twitter and facebook feeds which are displayed in the same way.
iBooks - FREE (Classics are free, most are same as the retail stores)
This is one of my favorite apps. I have bought many books as the convenience is brilliant. The books display clearly and the ability to dim/ brighten the screen easily is ideal for reading in different light such as a dark room or a bright garden. The app is linked to the iTunes book store which needs a few improvements such as the Genius feature of the music and app stores. It's still pretty early on so I'm sure they will be coming later down the line. The ability to read PDF's makes it ideal for downloaded brochures and magazines. The app can also sync ...
Continue reading (permalink)
Posted in 'Applications'.