Our DNA is written in Swift

Category Archive for ‘Parts’ rss

Rich Text Editing on iOS

For the past few days you’ve see me go on and on about this Open Source Project of mine. Sorry if this got a bit annoying to you but I am very passionate about bringing this functionality to a broad audience because I feel that UIWebView should not be used as much as it is. With the DTAttributedTextView from the GitHub project you can replace most of these and have way more control over the outcome.

Apple might finally add support for Rich Text Editing in iOS 5, coming Summer 2011. I suspect that the Pages app on the iPad might be a glorified test case for Apple for that. But even if that indeed comes to our Xcode, it will be end of 2011 that customers will have widely deployed iOS 5


Today I want to show you something completely different that is using the aforementioned project as a base and extends it to provide Rich Text Editing capability.

Read more

DTBannerManager 1.3

After having worked on the official MobFox Framework it was only logical that I would add support for this new ad network to DTBannerManager as well. Well honestly, I actually developed the framework inside of DTBannerManager and when it was done, I made it a static universal framework.

And then there was the goal of having a method to allow customers to purchase “Ad-Freeness” via an InAppPurchase. As with all IAP stuff you have to create your own UI for it, so I had a friend and designer create dual-resolution artwork for an X-button that you can link with your own IAP code or use DTShop.

Have a look at a video demo of these new features that I put on YouTube:

If you have purchased DTBannerManager source code access before then you find these updates in your repository if you refresh it.

DTChartView 2.0

I had originally begun development on my chart class for BabyBubbles, which required customizable charts to display various statistics on whatever babies you might have. At that time all of the view building and logic was contained in a view controller, DTChartViewController. This app was the first to launch with the 1.0 version and I’ve never had any complaints.

When I continued work on iWoman 2.0 I realized that it would make more sense to make the box with the chart a view of its own. Especially because I wanted to have the ability to show a small chart which would zoom to use the full screen when rotating your device. So I got to work on 2.0. Amongst other polishing I wanted to clean up the delegate/datasource interface to use method names that inform the developer that they belong to DTChartView.

That’s how the datasource protocol turned out. You can see that very little is required to get a chart to show, but there is a boatload of options to customize the appearance of the columns and lines.

@protocol DTChartDataSource
- (NSUInteger)numberOfPointsInChartView:(DTChartView *)chartView;
- (CGFloat)maximumValueInChartView:(DTChartView *)chartView;
- (CGFloat)chartView:(DTChartView *)chartView valueForPointAtPosition:(DTChartDataPointPosition)position;
- (NSInteger)numberOfLinesInChartView:(DTChartView *)chartView; /* default 1 */
- (CGSize)unitSizeInChartView:(DTChartView *)chartView;; // default: automatically calculated
- (CGFloat)minimumValueInChartView:(DTChartView *)chartView; // default: 0
- (NSArray *)chartView:(DTChartView *)chartView arrayOfValuesForBarsAtPosition:(DTChartDataPointPosition)position;
// column grouping
- (NSUInteger)chartView:(DTChartView *)chartView groupForColumn:(NSUInteger)column;   /* column grouping */
// customizing look
- (UIColor *)chartView:(DTChartView *)chartView backgroundColorBehindPointAtColumn:(NSUInteger)column; /* no fill if not implemented */
- (UIColor *)chartView:(DTChartView *)chartView colorForLineAtIndex:(NSUInteger)index;  /* default colors are provided */
- (BOOL)chartView:(DTChartView *)chartView drawCustomBarInRect:(CGRect)barRect onContext:(CGContextRef)context forLineIndex:(NSUInteger)lineIndex; // custom drawing of bars
- (BOOL)chartView:(DTChartView *)chartView drawCustomBackgroundInRect:(CGRect)barRect onContext:(CGContextRef)context backgroundType:(DTChartBackgroundType)backgroundType;
- (BOOL)chartView:(DTChartView *)chartView drawCustomDataPointAtPoint:(CGPoint)point onContext:(CGContextRef)context position:(DTChartDataPointPosition)position;
// horizontal axis customization
- (NSString *)chartView:(DTChartView *)chartView textForLabelInColumn:(NSUInteger)column;
- (BOOL)chartView:(DTChartView *)chartView customizeColumnLabel:(UILabel *)label;
// vertical axis label formatting
- (NSString *)chartView:(DTChartView *)chartView titleForLabelAtValue:(CGFloat)value; // custom formatting for y-axis labels
// legend
- (NSString *)chartView:(DTChartView *)chartView titleForLineAtIndex:(NSUInteger)index; // name for legend
// display of placeholder for empty chart
- (UIView *)viewForEmptyChartView:(DTChartView *)chartView;
- (NSString *)titleForEmptyChartView:(DTChartView *)chartView;

In the meantime another customer found DTChartView and purchased it. Every time this happens, this invigorates me and prompts me to to polish just a bit more. Helmut Neumann took it upon himself to take the 2.0 BETA and add it to the latest version of his successful cellphone usage tracking app.

Without any fear or reservation he pointed out all the shortcomings and drove me to iron out all those kinks. So finally, when he got the update approved it was at the same time the seal of approval that I wanted to get to allow myself to release version 2.0.

I’m always happy to hear when customers of the Dr. Touch’s Parts Store report on how happy my work made them.

“Two months ago i wanted to add Charts to HandyEtat, my well settled cost control app for T-Mobile Germany. I was already using My App Sales and liked the integrated charts. So I was quite happy to find DTChartView in Olivers parts store, espacially when noticing the unbeatable price and license conditions. DTChartView is feature rich, highly customizable and rock solid in execution. Integrating it into my App was “a piece of cake”. Oliver showed a great performance on taking over and implementing enhancement requests. The new version of HandyEtat got an overwhelming response from my customers, so I am very pleased with my decision to use DTChartView.”

DTChartView 2.0 is available on my Dr. Touch’s Parts Store. I’ve priced it so high because of the enormous amount of work that went into it, knowing well that this would limit the number of apps using it. But on the other hand it makes it a charting solution that can make your app stand apart from the competition.

Augmented Reality Plane Finder Trumps Charts

Pinkfroot is a small iOS dev shop in the UK who specializes on apps that show planes and ships on maps. I had the author Lee Armstrong on my podcast a while back explaining how they are getting the vehicle telemetry. Increasing numbers of airlines and ships are outfitting their vehicles with transponders that are transmitting data like current speed or destination and there are boatloads of volunteers worldwide who have receivers for these airwaves and share them with Pinkfroot.

They had already used my DTAugmentedRealityController part with a bit of success on a Shipfinder app Ships Ahoy!, but naturally this is only interesting for people who at least sometimes have water nearby to gaze at ships on. Most of us iPhone users are living inland and so for every ship we see, there are dozens of planes that pass over our heads.

Enter Plane Finder AR. For the first time there is an Augmented Reality app where it actually makes sense to point your iPhone at something and get augmented data for what you are looking at. Granted there are apps showing you names of mountain peaks, but – honestly – those don’t move so much and thus are way less interesting as something that happens to pass over you right now.

Plane Finder AR gives you a rotating mini map and labels for the individual planes. These tell you the designations of the planes, ground speed, altitude, origin and destination, and distance from you. It proves to be a great use case for my AR component. If you have the data (the more live the better) you can easily build an enticing app.

Just how enticing? Well, let’s check the charts (courtesy of Applyzer)

The audience is downloading this app more than the likes of Tom Tom or CoPilot who had been leading the Navigation Category. Which in my humble opinion makes perfect sense because while navigation is something that you might use every once in a while when driving somewhere, this app makes the air above your current location a more interesting place.


You have AdMob ads in your apps? Wondering if you could make a bit more money if you also had iAds were available?

DTBannerManager solves this problem for you. It allows for easily adding both networks to your code. Under iOS 4 it will first try to get an iAd because those also pay for just being displayed. If none is available then it automatically switches to AdMob, so your banner space is never wasted. It also features elegant sliding in and out of the banners and is able to display ad banners even over a tab bar controller, so they are always visible for maximum effect.

You might argue that there are free ad networks out there who promise to do exactly this for free. So why would you want to get this component from me. Well, from you you get full source code and you see exactly what is happening. Also there is no server-side ad mediation happening that might get you in trouble with Apple. I believe that as developer you don’t want to involve too many additional parties and introduce too many external dependencies. With DTBannerManager you continue own all parts of your code and have full transparency.

What’s also great is that you can use this component will work on both 3.x and 4.x iOS Versions. This way you can target the broadest possible audience with reaping the benefits of iAds if available.

Adding advertising is exceedingly simple:

	[[DTBannerManager sharedManager] addAdsToViewController:tabBarController];

Then you can just subscribe to the notifications to adjust the viewing area of your view controllers.

DTBannerManager is proving it’s worth already in GeoCorder [FREE]. There was a bug preventing “clicking through” in Ads that I have since fixed. The component is available through the Dr. Touch’s Parts Store.


I wanted to use a UISwitch in iWoman to select between Celsius and Fahrenheit for the temperature scale. UISwitch being in my humble opinion the quickest method to switch between two values. Unfortunately Apple does not give us any kind of customization capability.

Homick tried to fill this need by making a custom view and providing a photoshop file that you could change. But that’s not how we do things in Dr. Touchistan. I totally revamped Homick’s code and brought it up to snuff to what I needed. Most importantly the color and labels needed to be fully customizable IN CODE.

DTCustomSwitch is almost entirely written from ground up as a UIControl where you can customize the text and looks of of both labels as you please. Even set the background color. That so far fulfills my needs for iWoman 2.0, but if you have any ideas on how to even more customize it, let me know.

Peter Steinberger informed me that you can also drag the knob for sort of a “slow switching”, something I had not thought about initially. But so I spent a couple of hours honing the animation behavior to get as close to the original as possible. Now DTCustomSwitch even does that.

DTCustomSwitch will available via the Dr. Touch’s Parts Store for 50 Euros.


I’ve been approached by several parties asking for a component to capture live video. I did my homework but had to find that without access to a hardware-based video encoder it is not possible to get real time frame rates on iPhones.

Interviewing the maker of the ShowTime Video Recorder app for iPhone 2G and 3G enlightened me a bit as to what tricks they used to pull off their app. They use AVI containers for JPEG frames and PCM audio. Other people seem to have a bit of success with compiling FFMPEG on the iPhone. But generally MPEG4 does not use less CPU power than encoding JPEGs, it uses MORE, causing even worse frame rates for live video.

And that’s ignoring the licensing problems you get when selling an app that has a h.264 encoder. A double-whammy in non-feasability for FFMPEG, all the more reason to find out the truth of the matter.

So we set out to build DTVideoEncoder to see for ourselves what kind of performance we can get. Unfortunately it turns out that even on a 3GS we are getting a maximum frame rate of 5 frames per second when encoding live screenshots. Polar Bear Farm hinted that they are only able to get their performance (of around 6 fps) because of heavy assembly-optimizing the JPEG compression library . But they communicated a disinterest in licensing it for us to put into a sellable component.

So we were stuck. Until actually somebody told us that instead of live video encoding he just wanted to add JPEG files to an AVI container plus audio. Because the JPEG files where already compressed  he would not face the bottleneck of JPEG compression. Suddenly this specific use case reinvigorated the project.

Kris Harris – maker of the 8 Track Mind iPhone game – went back into the depths of the AVI documentation and polished up DTVideoEncoder to be usable for offline encoding and added the requested capability of adding an existing PCM audio file as soundtrack. Kris is a great developer and his code is awesome, I’m glad to have him on my Dr. Touch Core Team.

Here’s a demonstration of the Demo app that you get with the component.

DTVideoEncoder does not have any external dependencies. Because the external JPEG compression library did not yield any performance improvement over what’s built into the SDK we chose to go with the on-board method.

Hours and hours worth of research and coding went into in this simple to use component to warrant a price tag of several hundred dollars. But because of the limited utility we we set the price to the lower end of the spectrum, at 250 Euros. It might enable one or more interesting uses of offline-video on iPhone or iPad.



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.


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!