Posts Tagged 'Programming'

UIScrollView Menu

Here’s a detailed howto on implementing a useful-looking UI widget extension:

Digital Post, my newspaper app for the iPad, uses a number of custom user interface elements to build out the full user experience. One of these custom components is a horizontal topic selector that you can swipe and also tap to select individual topics…


Not terribly complicated, but a nice implementation, featuring just how easy it is to use UITapGestureRecognizer.

Continue Reading →

Tip: UITabBar Tint

So you may have noticed that unlike most controls in UIKit, there’s no way to mess with the tint color of a UITabBar. But let’s say you really really want to make your UITabBar look different: well, from the people who brought you that nifty BarTint tool, here’s how to go about that:

CGSize tabBarSize = [tabBar frame].size;
tabBarFakeView = [[UIView alloc] initWithFrame:
CGRectMake(0,0,tabBarSize.width, tabBarSize.height)];
[tabBar insertSubview:tabBarFakeView atIndex:0];
[tabBarFakeView setBackgroundColor:[UIColor redColor]];

… and apparently the buttons will get drawn acceptably on top of whatever color/image/whatever you stick a view in there for. We’d be just a teensy little bit nervous that the SDK Police might consider this “undocumented API”, having encountered issues of that sort before, but hey, if somebody really really wants their UI to look just so, there you go!

Continue Reading →

Instant Translation

Think it’d be neat to embed Google Translate facilities directly into your app? Well, in case you didn’t know, there’s a public AJAX Language API for that, and it’s pretty dead simple to put into your iPhone app:

Google Translate and iPhone apps

Only available while online of course, and chances are that there’s licensing restrictions that you’d better be aware of, but hey, free insta-translation of any sort is pretty nifty!


Ray Wenderlich now has, of course, a detailed tutorial on the subject:

How To Translate Text With Google Translate and JSON on the iPhone

Continue Reading →

Syntax Coloring

Here’s a good start for you if you’re tasked with writing a syntax coloring editor: The “vital pulp” (as they put it) of text editor Smultron, now being further developed as a fork named Fraise, is now packaged up as an Apache-licensed framework named Fragaria. (Where do they get these names from?)

NSTextView-based, so not of immediate application to your iDevice coding, but hey it’s something!

h/t: cocoadev!

Continue Reading →

Pull-To-Reload UITableView

So this may be old news to you, but the official iPhone Twitter client (née Tweetie 2) has a super-nifty interface enhancement where to reload your tweets you pull down the top of the list and it gives you a prompt to refresh. Pretty cool, huh?

Well, here’s an explanation with complete source of how to add it to your own projects!

How to make a Pull-To-Reload TableView just like Tweetie 2

Working implementation available for €20 with the My App Sales source, if you’d like that, but like most things, it’s pretty straightforward once someone shows you how.

… and apropos of discussing things Twitterish, should your image there be of large concern to you, you might find amusing/educational this semi-rant: Elements Of Twitter Style. Whilst personally we haven’t actually embraced Twitter past installing Duane’s nifty WordTwit plugin to treat it as an alternative RSS feed essentially, we’ve grudgingly acquiesced that there are some feeds out there with enough interesting content to bother devoting a modicum of attention to. Yeah, we know, doesn’t sound very much like a troll, getting involved in anything social media-ish, does it. Cha, what next, signing up for Facebook? The horror!


Here’s another simple and free implementation: iPhone Pull to Refresh!

And another: EGOTableViewPullRefresh!

Yet another: SSPullToRefresh!

h/t: @rwenderlich!

Continue Reading →

C99 Tricks

So you think you know the C programming language? Well, we’ll just betcha that you’ll find out something new by checking out

Fun with C99 Syntax

The C99 language added some pretty neat features to the ANSI C we know and love (now known as C89). I used a construct called compound literals in my iPad Dev Camp presentation, and it seemed new to a lot of people. Here’s a summary of some lesser known features about C99 that are worth knowing. And, since Objective-C is a strict superset of C, all this applies to Objective-C, as well. Best of all, as of recent Xcode (3.0? 3.1?), C99 is the default C dialect for new projects, so you don’t need to do anything to start taking advantage of these…

Continue Reading →

Sparrow Framework

Here’s a new open source iPhone game programming library for you: Sparrow!


Sparrow is a pure Objective C library targeted on making game development as easy and hassle-free as possible. Sparrow makes it possible to write fast OpenGL applications without having to touch OpenGL or pure C (but easily allowing to do so, for those who wish). It uses a tried and tested API that is easy to use and hard to misuse…

“But wait!” you think no doubt, “aren’t you a big fan of cocos2d in your game projects?”

Why, yes, yes indeed we are; but there’s a clue in the above as to why this Sparrow thing is worth knowing about anyways. That clue is “a tried and tested API.” What does that mean? Well, it is explained more clearly here:

… But the killer feature of Sparrow is the following:

Many of you will already be familiar with it.

How come? It’s very similar to the Flash API. Anyone who has made a Flash game will feel at home instantly. You have got all the classes you are familiar with: DisplayObject, Sprite, TextField, etc. You can use the same event model, including bubbling events, etc. We only made some minor changes where we thought it made sense to do so. (E.g.: instead of the class couple “Bitmap” and “BitmapData”, you have got “Image” and “Texture”)…

So since due to the Steve Jobs Objective-C Developer Full Employment Act (aka Section 3.3.1) you may find yourself in the position of considering a Flash project port to a native application, this looks like it could indeed be an appropriate tool for that task. If so, here’s a tutorial to get you started!


And here’s another: Animations In The Sparrow Framework Game Engine Explained!

Continue Reading →


There’s a new version out of AQGridView — which, hmmm, doesn’t look like we’ve actually mentioned before, although the thought had crossed our minds when we saw news a little while back of its Best Developer Tool win at iPad Dev Camp. So what is this award-winning piece of spiffiness, you ask?

AQGridView is an attempt to create something similar to NSCollectionView on the iPhone. If CALayoutManager were available on the iPhone, specifically the CAConstraintLayoutManager, then this would be relatively easy to put together. However, since none of those exist, there’s a lot of work to be done.

AQGridView is based around the programming model of UITableView and its associated classes. To create this class I looked long and hard at how UITableView does what it does, and attempted to replicate it as closely as possible. This means that if you are familiar with table view programming on the iPhone or iPad, you will find AQGridView simple to pick up…

Originally written for the Kobo ebook app — free to check out!

Continue Reading →


If you want to pass your Objective-C objects across a network connection, this may be worth looking into:

There’s a few problems with Distributed Objects that bug me:

1. Uses exceptions for errors, which just feels unnatural and cumbersome in Cocoa

2. Claims to be capable of more than it really is, such as sending any single ObjC message call over the net (see mikeash’s example regarding -getObjects:range:), and acting like a normal Cocoa object

3. Defaults to synchronous message calls, potentially over the internet(!)

4. It’s guts are not interchangeable, meaning you cannot fiddle with the lower level parts at all

The framework SocketObjC is very similar to Distributed Objects, with a few major differences:

1. All messages are sent asynchronously

2. The underlying message passing system simply uses TCP via AsyncSocket

3. Instead of exceptions, problems are simply ignored (this could easily be fixed by anyone)

4. Messages with return values can handle those returned values using block callbacks, making use of what I later learned is called “Continuation Passing Style”

5. Limited to passing and returning objects that conform to NSCoding

6. Possible to add support for secure TCP message sending (via CFStream/CFSocket, via AsyncSocket)

As you can see there are some trade-offs, for better or worse. But all in all I think this is more useful than DO for passing messages across the internet.

h/t: !

Continue Reading →


Got a need to integrate Flickr support into your iPhone or desktop app? Well, here’s the open source project for you:

ObjectiveFlickr is a Flickr API framework designed for Mac and iPhone apps.

Yes, straightforward enough and you’d probably have googled it yourself if you need it, but we’d like to draw your attention to this interesting idea that might not have occurred to you about how to integrate web pages and iPhone apps:

…iPhone and iPod Touch posed a challenge to the auth model above: Opening up Mobile Safari then ask the forgetful user to come back is a bad idea.

So many iPhone developers have come up with this brilliant idea: Use URL scheme to launch your app. It turns out that Flickr’s web app auth serves the idea well. Here is how it works:

   1. The app prompts user that it’s going to open up browser to ask for permission.

   2. The user taps some “Open” button, and the app closes, Mobile Safari pops up with Flickr’s login (and then app auth) page.

   3. Then magically, Mobile Safari closes, and the app is launched again.

   4. There’s no Step 4.

What’s behind the scene is that the iPhone app in question has registered a URL scheme, for example someapp:// in its Info.plist and the app developer has configured their Flickr API key, so that when the user grants the app permission, Flickr will redirect the web page to that URL the app developer has previously designated. Mobile Safari opens that URL, and then the app is launched…

Well yippee, perhaps you are thinking, now when would I ever care to jump out to Safari and back when I’m writing an app?

Ah, let me tell you when you would care to jump out to Safari and back when you’re writing an app.

You could care to do that if you write an app that loads up a web page to make a donation in a UIWebView, and when you send your shiny new app off to Apple, BRRRRAAAANNGGG it bounces back with

Thank you for submitting [REDACTED] to the App Store. We’ve reviewed [REDACTED] and determined that we cannot post this version of your application to the App Store because it does not adhere to the charitable requirements outlined in the iPhone Developer Program License Agreement …

… Donations are not permitted to be taken within the application, however it is possible to provide a donation link to your web site. This link is required to open Safari to collect the donation. We encourage you to make the necessary changes to your application and resubmit it for review.

Well, the license doesn’t say it has to open in Safari, it just says “a direct link to a page on Your web site”. And that’s exactly what was in the UIWebView, @#($@^#$^!!! it. So we duly complied and resubmitted, but it makes the experience significantly more annoying. But if this clever stratagem had occurred to us, we could have had the opened-in-Safari page open back up the triggering application. That would have made for a happier client!

Continue Reading →
Page 62 of 95 «...3040506061626364...»