FlurryAds Interstitial ads with Cocos2d v3

This is my first foray into ad-supported territory. I am really liking Cocos2d and recently my focus has been on the newest v3 (currently rc4). In this tutorial we will put up some interstitial ads for iphone and/or ipad.

Cocos2d v3 has a great new installer. It gives you a couple options in XCode. It’s even compatible with the latest XCode (5.1) and ARC.

-all those frameworks.
AdSupport.framework (Mark as Optional to support < iOS 6.0)
CoreGraphics.framework
Foundation.framework
MediaPlayer.framework
Security.framework
StoreKit.framework (Mark as Optional to support < iOS 6.0)
SystemConfiguration.framework
UIKit.framework

//do the first delegate stuff
In the AppDelegate.h go into the
-(BOOL) application: didFinishLaunchingWithOptions:

[Flurry setCrashReportingEnabled:YES];
[Flurry startSession:@"YOUR_API_KEY"];
[FlurryAds enableTestAds:YES];

Continue reading

Easy way to see (and debug) UILocalNotifications

It doesn’t take a lot of code to create a UILocalNotification but when you have multiple of them and you’re doing a lot of calendar math and things start getting hairy. To demystify that experience I created a project with a UITableViewController that prints out all of the current UILocalNotifications.

We’ll create 3 local notifications 1 minute apart for the next 3 minutes with these calls:

   [self createLocalNoticationAt:[[NSDate date] dateByAddingTimeInterval:60] withTitle:@"Every Minute 1!"];
    [self createLocalNoticationAt:[[NSDate date] dateByAddingTimeInterval:120] withTitle:@"Every Minute 2!"];
    [self createLocalNoticationAt:[[NSDate date] dateByAddingTimeInterval:180] withTitle:@"Every Minute 3!"];

Continue reading

Detect the end of a UILongPressGestureRecognizer

I am coding the previous/next buttons of a music player. I need these UIButtons to have dual purpose.

1. Tap – Previous/Next song
2. Long Press – Seek

That works, but what got me was that I didn’t know when the end of the long press was so I never knew when to stop seeking. I tried to attach an action to the UIButton on the UIControlEventTouchCancel event, but that is not correct.

This is my setup code:

    gestureSeekBackward = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(seekBackward:)];
    gestureTapBackward = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(previousSong:)];
    gestureTapBackward.numberOfTapsRequired = 1;
    [backwardButton addGestureRecognizer:gestureSeekBackward];
    [backwardButton addGestureRecognizer:gestureTapBackward];

What I needed to do was check whether the state is ended for the seek gesture. Continue reading

Change $PATH in Mac OS X Mountain Lion

I’ve had a bad time trying to get Jewelry Box running on Mountain Lion. I simply didn’t know how to edit my current $PATH.

Turns out there is a list it takes from at /etc/paths

I quickly changed the order and then after a trip to thew ‘brew doctor’ everything seems fine and now I’ve got ruby 2.0.0!

After much searching this is the great resource which I found:
http://daniel.hepper.net/blog/2011/02/change-order-of-path-entries-on-mac-os-x/

Chaining UIView animations with blocks

I really love UIView animations. They are so simple and elegant. This little chain I will make will fade in a UIView (or descendant) from the left, wait a moment, then fade out to the left. In general you can animate all of these properties: frame,bounds,center,transform,alpha,backgroundColor,and contentStretch in a UIView animation block.

For this example I created a single view application and put a UIImageView in the middle of the screen. UIImageView is a direct descendant of UIView so it is perfect for this exercise.
UIImageView
Continue reading

UITableView Disclosure Indicator on a UIButton

Although it is non-standard. I needed to match pixel-perfect to a design, so I created this. On a UITableView it is called ‘Disclosure Indicator’ as opposed to the one available from UIButton which is ‘Detail Disclosure’.

table_indicator

It is 50×80 with a transparent background. Use this image on top of a button or UIImageView. Resize it to whatever size you’d like your button to be. Apple recommends a hit target of no less than 40×40. I sized it to 10×16 in my storyboard, but I am using a transparent button overlay so the size doesn’t matter.
Continue reading

Configure a UIScrollView entirely in Storyboard with Interface Builder

Usually even if you drop in a UIScrollView, put a UIView into that and align them correctly it still does not work. Why? It’s UIScrollView.contentSize. Now we can easily do this in code, but it is also easily accomplished in Interface Builder.

The first thing I’ve done is drop in a UIScrollView, pop a UIView inside of it and then populate my controls into said UIView. We can verify this by looking at the hierarchal view.
UIView inside UIScrollView
Continue reading