iOS Development

Blog about iOS development, experiences and upcoming projects

0 notes

TTStyledText problems with special characters

A few months ago, I worked on a contract app for a german user-generated local review platform. I should integrate an activity stream with touchable links. Similar to Facebook’s stream, where you have a lot of different links to touch, which enables different actions. I decided to use TTStyledText from the tremendous three20-framework. Everything worked well, but after a few tests I ran into a problem. Sometimes the touchable link was missing, but the rest of the text was still visible. (Screenshot)

A few debug sessions pointed out that some special characters were the problem. Such characters which should normally be escaped, when you use them in context with html. The solution was to write a NSString-Addition, which solved the problem. (Screenshot)


@implementation NSString(TTStyledTextAddition)

- (NSString *) stringByEncodeWithHTML{
	NSString *string = [[self copy] autorelease];
	string = [string stringByReplacingOccurrencesOfString:@"&" withString:@"&_amp;"];
	string = [string stringByReplacingOccurrencesOfString:@"" withString:@"&_gt;"];
	string = [string stringByReplacingOccurrencesOfString:@"\"" withString:@"&_quot;"];
	return string;
}
@end

Note, please remove the _ between &_amp, &_lt, &_gt, &_quot. I have to integrate them because the text was rendered wrong on tumblr (shows the real symbols… it’s html of course ;))

Hope that helps somebody.

Filed under three20 special characters html iOS problem

0 notes

Tracking taps on an animated UIView

A problem in which i ran a few weeks ago, was how to track touches on a UIView which is animated at the moment.

My first idea was to add an UITapGestureRecognizer to my view. This worked really well while the view was not animated. When you started the animation, nothing happened when you tapped on the view.

The next approach was to override the UIRecognizer methods of the view, but this ended in the same result. 

Finally I could solve the problem. I used a parent view to keep track of the touches. I added the animation view to my parent view. When touches began I made my own hit test to check wether the user tapped on my view or not. While the view is animating I use the CALayer’s presentationLayer for my custom hit test.

You can download the example source on github.

Filed under iOS taps on animated UIViews UIViews animation UITapRecognizer

0 notes

Why I am using Tumblr?

It’s a good question.

Well the reason why I am using Tumblr, is quite simple. I am currently downloading the newest iOS SDK on my Macbook. Usually I don’t work on my Macbook, that is the reason why I never have the latest SDK installed on it.  

While downloading the SDK, I was searching for another activity… because I have had no homepage so far, I decided to try Tumblr as a replacement…. maybe this will work for me.

As you can see the reason is really simple ;)

Stay tuned for more informations about my projects and my iOS experiences.