Archive for 'iPhone'

UIWebView tips

Here’s a useful collection of tips on using UIWebView:

- Loading the SVG file from your resources folder
- UIWebView loading contents when it is off-screen
- Calling a javascript function from Objective-C
- Javascript communicating back with Objective-C code
- Disabling the selection flash
- Disabling the “action” pop-up
- Disabling default zoom effect

Something there for everybody. And here’s one more:

Common problem, need to apply nice HTML formatting for a section of your page, but want the UIWebView not to appear as a big white box – only the content of the UIWebView to appear. How to do it?

myWebView.opaque = NO;
myWebView.backgroundColor = [UIColor clearColor];
[myWebView loadHTMLString:
@"<html><body style='background-color: transparent'>
       Content Here</body></html>" baseURL:nil];

Now you know!

Continue Reading →

Screen Capturing

Thinking of making a video of your iPhone application running like it seems all the cool kids are these days? Well, if you don’t want to fool around with real video, here’s a couple tools that make screen capture more elegant so you can produce said video using the simulator: SimFinger and PhoneFinger!


[EDIT: And for the screen capture itself, here and here are experiences using ScreenFlow ... but if you have any comments for or against the many other Mac screen capture programs out there, feel free to share!]

Continue Reading →

Code: Reachability

Whoops, here’s something we’d overlooked in our latest app effort — good thing we stumbled across this before submitting it! — if your application is network dependent, apparently Apple requires that you detect network availability proactively, spinning helplessly in its absence is not sufficient. From this top 11 list of rejection reasons:

6. Popup for network detection If your app requires the use of the Internet, you must detect when the network is unavailable and provide a pop-up message informing the user. Just having the spinning busy icon display and a message saying “trying to connect” is not sufficient. Apple will reject your app if you don’t provide a message informing the user that they need a network connection.

Ah, OK then. No worries, we’ll just grab the Reachability sample … wait, what?

7. False claims of a missing network On a related note, make sure you don’t have any false positives in your network detection. There’s a bug in the “reachability” functions provided by Apple. If you don’t first try to perform a network connection but instead just do a reachability test, the code will always report the network is unavailable. Apple will reject your app if they discover you have this false positive case.

Actually, it looks like what I presume is the “bug” referred to above in Reachability is indeed not such … not exactly, anyways. The trick is, you want your first status check of your target host name’s reachability to be made synchronously. Because, until it completes the check, well, it’s not connected, is it now? Quite logical, really. And once that initial check is sorted, then your updates should properly be asynchronous. So in Reachability’s appDelegate where it has

[[Reachability sharedReachability] setHostName:[self hostName]];
// The Reachability class is capable of notifying your application when the network
// status changes. By default, those notifications are not enabled.
// Uncomment the following line to enable them:
//[[Reachability sharedReachability] setNetworkStatusNotificationsEnabled:YES];
[self updateStatus];

that’ll always return false for your target host reachability in -updateStatus if you follow the given instructions. Whoops! To fix that, simply do a synchronous then an asynchronous query

[[Reachability sharedReachability] setHostName:[self hostName]];
[self updateStatus];
[[Reachability sharedReachability] setNetworkStatusNotificationsEnabled:YES];
[self updateStatus];

… and you’re all good.

It would be more clear that the first host reachability check failing was a foreseeable occurrence if -setNetworkStatusNotificationsEnabled was actually labelled -setStatusResultsAsynchronous. Or, even better,
-callThisToMakeTheSampleFailHaHaSucka. But Apple very rarely labels sample code quite that honestly!

Continue Reading →

Testing: Squish!

Something to keep your eye on here: An upcoming GUI testing tool for your Cocoa Touch applications! Yep, the most deliciously named froglogic is promising a version of their Squish testing tool by “the upcoming Squish 4.0 release”, whenever that is.

Squish is a professional, cross-platform GUI and regression testing tool that enables testers to create and execute automated GUI tests for applications based on a variety of different GUI technologies. This includes applications based on Nokia’s Qt, Mac OS X Carbon and Cocoa, Java SWT/Eclipse RCP, Java AWT/Swing, Web/HTML/AJAX, and many other UI technologies. Squish stands out from other GUI test tools thanks to its close integration with each supported GUI technology—a feature which helps ensure that tests created with Squish are very robust and stable.

That’s quite the feature set, isn’t it now. Any of our Gentle Readers have any experience with Squish on this plethora of other platforms and have an opinion of how exciting this news actually is?

h/t: Jeff!

Continue Reading →

Code: L0SolicitReview

Well, this is an innovative approach to the problem of getting good reviews on the App Store: just go ahead and ask for them!

We all agree that having JUST negative solicitation (that is, Apple’s rate-on-delete) is bad, whether we agree or not that having it is a good thing (I think it is). What we lack is a way to solicit positive reviews from satisfied users to counteract the rate-on-delete ratings slump.

Well, here it is:

Find it on Google Code as part of the author’s UIKitPlus project; dunno if it will actually help with the negative selection problem … but it very likely isn’t going to hurt. One can hope.

h/t: iPhoneSDK!


Here’s another class for the prompt for reviews and ratings kind of thing:

Presenting, Appirater

Continue Reading →

Tip: iPhone Serial Number

So isn’t it annoying that when you need somebody’s iPhone ID for setting them up for Ad Hoc distribution and the like, there’s no way to easily copy it from iTunes? Well, here’s a handy way to get it as text. Plug it in, and have them go to and enter

system_profiler SPUSBDataType | grep 'Serial Number'

and just tell them to copy the text that appears!

Serial Number: eb2342b2feh5209e845fa7428e60f27a5ef93b7d

Ah, that’s much easier than relying on screenshots or questionable transcription abilities, isn’t it now?

[EDIT: Well, ok then ... apparently sometime since I did my first provisioning, iTunes got smart enough to actually copy the phone's ID when displayed. See first comment. My, you readers are so clever!]

[EDIT 2: No, wait -- there's actually an app, Ad Hoc Helper, from the redoubtable Erica Sadun up on the App Store for free to have your intended tester just email it to you directly. There you go. Brandon wins for that tip!]

Ad Hoc Helper

Continue Reading →

Code: SCListener

Here’s a good start for you if you’re interested in putting some microphone-activated features into your iPhone app:

Voice activation. Sounds cool, doesn’t it? And all the cool people are using it! Nintendo was on to something with their DS and its microphone: Wario’s little games were no match for a little heavy breathing. With the iPhone, Smule is using it up a storm! And iSteam? Yes! These guys get it: people love doing stuff with their mouths! If there’s some kind of reward involved, well then, now you’re talking. Blowing out candles, kissing, outright yelling up a scene—these are the things of life, right?

Yes, indeed. We’ll just lightly skip past that mouths bit, for the sake of our gentler readers, and focus on the code: it’s called SCListener and it’s on github for you to download. That’ll get you the input set up and metered … and off to the races with your blowing application. Er, we mean the application that you blow … er, no, we mean … yeah, well, you know.

Continue Reading →

OpenAL resources

So if you’re an old school Mac programmer, you’re probably vaguely aware that OpenAL is a fully Apple-supported API on the iPhone as well as desktop OS X these days, but haven’t looked into it all that much yet … hey, there’s all that CoreAudio code of yours sitting around that works fine, right? Well, yes, but there are good cross-platform reasons, particularly if you’re into that gaming thing and have a use for multitrack positional audio, to get familiar with it. The canonical destination is the above linked home, but here’s some iPhone-specific links of interest:

iPhone Programming Part 6: Multiple Sounds with OpenAL

This provides a handy-dandy Cocoa singleton wrapper class for your OpenAL management.

iPhone, OpenAL, and IMA4/ADPCM

How to decompress IMA4 audio files and pass them to OpenAL for playback. Smaller is always better!

OpenAL FAQ for iPhone OS

Never overlook the technical notes! It’s always worthwhile doing a full text search for those to catch stuff that isn’t in the formal documentation for a given API. As well, don’t miss the various Apple-blessed OpenAL sample code:


Basic example showing OpenAL usage in a 2D OpenGL environment. This sample demonstrates how to bind OpenAL sources to OpenGL objects to create an audio environment.


The code uses OpenAL to play a single audio source. Move source or listener position by dragging icons around on the grid. Turn accelerometer functionality on to set listener orientation by tilting the device.

Anything else to add to this list, Dear Readers?

Continue Reading →

UITableView Tips

Here’s a couple useful discussions on UITableView for you:

Resizing a UITableViewCell to Hold Variable Amounts of Text

In part one, I demonstrated how to use a UITextView and a UITableViewCell to create a field for users to enter large amounts of text. After the text is saved, I’d like to display that text in a different table. The problem is I don’t know the height of the text. I’ll tackle that problem now…

Organizing a complex UITableView by using a dispatch table

One problem with the table view is that the controller class tends to get very large and complex, especially if you have a multiple section table view that has different types of custom cells and behaviors … I’ve developed a technique that can make use of this technique but that goes beyond it by allowing you to delegate the handling of each section in a table view to its own class. It is also easily configurable if you need to add or remove a section type from your controller later, and allows you to localize your changes so that you don’t have to remember to modify code in several places.

Good stuff!

Continue Reading →

Code: Google Docs

Now here’s an interesting idea: Use Google Docs to provide free data sharing in your iPhone app.

In September, my small software company shipped our first iPhone app, a grocery list program called Grocophile. One of the most common requests from our users was the ability to exchange data over the Internet. Greg Robbins of Google’s Mac team suggested that the Google Docs API might be useful, so I jumped in and took a look.

This turned out to be a great way to give our users access to free Internet storage, letting them back up their data and share it across multiple devices…

…  If your app can store and retrieve its data in text, HTML or a spreadsheet, then Google Docs will work well for you. 

That does cover a wide variety of data, indeed. There’s source code here to check out if this sounds like something you’d want to look into!

h/t: iPhoneKicks!

Continue Reading →
Page 80 of 98 «...5060707879808182...»