Our DNA is written in Objective-C

UIImageView + Touch Handling = UIButton

gdscei asks:

“Hello, how can i make an image view work as a button? I want it to be assigned to the ‘reload’ action of WebView.
Can someone give me instructions how to do this?”

Often people start out constructing their UI visually, starting with this line of reasoning “I want to show an image. Ah, UIImageView”. So they create the visual appearance of their UI either by clicking it together in Interface Builder or – if slightly more advanced in their coding skills – creating those image views in code.

So if we create a new view-based project in XCode, we could modify the viewDidLoad of the main view controller like this to show the image:

- (void)viewDidLoad {
    [super viewDidLoad];
	UIImageView *imageView = [[UIImageView alloc] initWithFrame:
		CGRectMake(100.0, 100.0, 57.0, 57.0)];
	imageView.image = [UIImage imageNamed:@"Icon.png"];
	[self.view addSubview:imageView];
	[imageView release];

The next logical step in reasoning right after displaying the icon is now to get touch handling somehow. And that’s where you will get stuck because UIImageView is a dead end when it comes to reacting to the user’s finger.

Read more

Making a "Follow us on Twitter" button

I am working on the ultimate “About Page” component at the moment. And of course this won’t be complete without a button to follow the developer on Twitter. Tapbots is one company that has the best role model for modeling this. They have this little button here at the bottom of their about page:

There is something amazing that happened when I tapped on this “Follow us on Twitter” button: it opened up the tapbots user right in Tweetie 2! I was astonished at first, but then it dawned on me that on the iPhone you can have your app respond to a custom URL scheme and obviously some Twitter clients support going to the user’s profile page. I have only Tweetie 2 installed and incidently this supports just that.

Read more


When experimenting with the iPhone’s built-in LED font I found it severely lacking in terms of usability. It’s designer has had the glorious  idea of not making all numbers the same size. This means that if you have any kind of changing label (like for example a digital clock) then the contents of the label will jump around as digits change size. This is especially annoying going from or to a one which is extra slim.

Generally my instinct is to use regular smooth fonts for display of numbers, but I find that every 2 or 3 months I get into a situation where the classic LED look would be the perfect gimmick. For example I am still pondering how to make the UI of GeoCorder more attractive and one idea was to have the measurements be displayed in LED numbers.

So I set out to create a reusable solution for this problem. A quick search on Google gave me this image from iStockphoto. It does have their watermark, but I was not going to simply off their images. Instead I used it as a template to construct a resolution-indendent drawRect for my DTLEDDigitView. The resolution was just big enough so that I could find the edges in my image editor and make the appropriate connections.

Basically you cut out the 8 which has the best contrast on all sides and then you get the coordinates of each corner of each bar. To make it resolution-indendent you then multiply each value with a unit size for width and height so that this scales nicely. The main reason why I wanted it to be resolution-independent is that this will look nice very small but also on the many extra pixels that are available on the iPad. So if you use DTLEDNumberView you don’t have to worry about static LED number images being scaled into fuzzyness. My solution is always crisp.

Then I added code to turn on and off single bars depending on the digit property. Also I wanted to be able to control the dot, so I added a property for that. Activated bars are paths filled with this distinct red, non-activated bars are 100% white with 30% alpha so they will lighten any background slightly. That’s all about the drawing.

Very useful when creating custom views like this is to fill in the sizeThatFits method with some algorithm that will adjust the width and/or height accordingly. In this case I am using it to find a scaling where the aspect ration of the numbers still fits in.

Then I took the DTLEDDigitView and made a view to add to itself as many such digits as a property numberOfDigits would decide. Optionally there is a property numberOfDecimalPlaces which decides how far from the right the comma is. The final touch is to have a value property and to adjust all the individual digits accordingly if it changes.

Here’s my demonstration video, it simply adds PI every tenth of a second so that you see the numbers change, also behind the comma.

I can immediately think of a number of useful customizations, like changing the colors for active and inactive and maybe adding a neon glow to the active bars. But for lack of a concrete application with it’s requirements I won’t fiddle around with it until there is one. I need either myself or somebody else to have an app to add this component to so that I know the final tidbits necessary.

The whole thing took me about a day to make so I’ll set the introductory price at 50 Euros. If you’d like to use this technique in your own apps, drop me an e-mail so we can discuss what extra features you would require to make the purchase.

GeoCorder 1.0.4

It’s been almost a year since my last update to GeoCorder, which is a handy little tool to quickly record GPS tracks and mail them to yourself for viewing in Google Earth or geotagging photos. It’s a very simple tool which I wrote to get GPX tracks for my own testing. If you believe the reviewers it serves it’s purpose very well

Since then SDK 3.0 was released and with it the possibility of sending attachments in E-Mails. Before that time I had to resort to sending the files via my own web server, but with this update this is now no longer necessary. And lately some reviewers started to complain about this old mode so I finally found a day to sit down and polish it up, fulfilling all the reviewer’s requests.


  • NEW: Set a distance filter to conserve battery life
  • NEW: Export via E-Mail now uses InApp E-Mail (if available)
  • InApp E-Mail: optional compression of sent GPX files
  • InApp E-Mail: GPX file now named with timestamp
  • German localization
  • Minor UI tweaks

The update covers GeoCorder and GeoCorder [FREE] and has been submitted to Apple for approval.

UPDATE: 29 hours later the update(s) are through the review process. That’s new record for me.

Developer Name Calling

I decided to concentrate on the iPhone platform back in Fall 2008 shortly after the general availability of iPhone SDK 2.0.  Since then I was frequently facing the necessity of describing what I do in a few words. Generally I described myself as “iPhone Developer”. But then two generations of the iPod Touch became just as important in sales as 3 generations of the iPhone and now Apple is releasing yet another category of device running iPhone OS, namely the iPad.

So the name “iPhone Developer” does not really feel like it encompasses all 3 device types. Especially if you are talking to laymen who don’t know about the OS being the common ground between all of them. So I asked the Twitterverse, with interesting and sometimes hilarious results.

“What should we call a developer who concentrates on developing for iPhone, iPod Touch and iPad”?

Read more

Understanding UIFont

Have you ever really TRULY looked at the documentation of UIFont?

I had to, because I was looking for some metrics information that I could use to custom draw UILabels. And if you want to be independent of what font is set, then you have to get certain metrics, but the Apple SDK documentation of UIFont leaves a bit to desire.

When I asked which characters would be good representatives of a font, I was sent a link to this blog “celebrating the beauty of the ampersand”. Fine, an ampersand will be there as well…

Read more

How to deal with contracting customers who won't pay

If you do a bit of contracting besides or publishing your own apps then you will have to deal with a wide spectrum of human beings. Some appreciate every tiny tidbit of love you put into their apps. Some of the more entrepreneurial kind will constantly come with new ideas but always assume that those where part of the initial agreement.

I’ve had an encounter with an illustrious specimen of the second kind and so I thought it would be therapeutic for my hurt pride to ask the tweeting community about their opinion. Here are the responses for a view of what other iPhone developers generally think about this topic. I got a big number of responses which for the most part contain good food for thought.

Read more


Typically you would use Default.png to show an empty user interface to reuse the subjective loading time of apps. This is especially true for productivity apps. Games are an example of the opposite. There you often see several splash screens with logos and copyright information. Between those extremes there are apps that use licensed materials and where it makes sense to briefly show such licensing information right at the start. The loading screen however is only showing for as long as the app needs to start up, which can be extremely short if the app is well coded and/or running on an iPhone 3GS.

So out of the need to display the loading screen”a bit longer” resulted revelopment of DTSplashExtender.

This new addition to my Dr. Touch Parts Store gives you this exact capability in a worry-free package. With this method you set a timeout of several seconds for which the Default.png is shown extra. You can have subsequent images that are faded to after the time has elapsed and show multiple pages with logos this way. When the show is over you dismiss the modal DTSplashExtender controller, your choice of flip, cross-dissolve or slide down.

There are delegate methods that you can hook into in your app delegate to perform certain actions when a certain page is showing. Additionally you can enable a feature where tapping the screen ends the show or fades to the next page right away. For example you could show a button to prompt the user to accept your licensing terms. Let me know if you have special requirements.

Here’s a quick demo:

DTCalendarView 2.0

When I saw the demo video of Billings Touch it hit me like a cold snowball: it also makes sense to use a calendar to select a date. Billings Touch shows you a nice big calendar view when you select a project due date. Shortly thereafter there was a discussion on date pickers on my favorite forum and the result of this also pointed towards the necessity of having a real calendar replace UIDatePicker.

So I sat down for 2 days straight to surgically remove the calendar-related parts from DTCalendarViewController and put those into their own class DTCalendarView. This enables you to use the view by itself. Also I put my secret sauce UIView+sliding into the project, as a free bonus. This category extension allows you to slide in any kind of UIView from the bottom of the screen. Together with DTCalendarView you get magic: a drop in UIDatePicker replacement!

Additionally to the above new features there where a couple of minor bug fixes and programmability improvements that will make your life as developer much easier. The update for DTCalendarViewController is free of charge for existing customers. To order your access and license go to the Dr. Touch’s Parts Store today!

Dr. Touch #012 – "iPad Aftermath"

A week after Apple announced the iPad the dust has begun to settle. Dr. Touch explores what the iPad really means for us developers.

This episode is brought to you by:

Dr. Touch’s Parts Store – easy to use yet professionally looking components that you can use to spruce up your own apps. Augmented Reality, Calendar Control, Pin Lock or Purchase Button are only some examples. You get full source code, no static library crap, and lifetime support by Dr. Touch himself. Check it out today!


My Show Notes (aka Script) below the break…

Read more