0

I'm using GLTapLabel for a project and almost everything is working fine.

When I try to show a text starting with a + or any other special characters, the whole thing looks like this: Screenshot 1 (left: the output in the simulator, right: the text in the interface builder).

Normally it works like a charm as seen in ScreenShot 2.

I think it has something to do with this line from GLTapLabel.m (in the drawTextInRect function):

while ([s scanCharactersFromSet:[NSCharacterSet symbolCharacterSet] intoString:&read])

Is there any solution? Am I just missing something? I've never done something before with NSScanner.

Marcel Jackwerth
  • 53,948
  • 9
  • 74
  • 88
Nicolai
  • 328
  • 2
  • 10

1 Answers1

1

I just came across this problem last night and it took me 3 hours to figure it out. You were on the right track with what was going wrong but it has more to do with the range. Anyways forget about the problem just replace the last while statement with my solution and you should be good. I've added a few comments so you could follow along to see what I did. Enjoy!

 while ([s scanCharactersFromSet:[NSCharacterSet symbolCharacterSet] intoString:&read]) { //symbolCharacterSet
        for(int idx=0;idx<read.length;idx=idx+6) //For Some Reason "6" works with + sign and Emojis... 

        {

            NSString *word=[read substringFromIndex:0];  //substringWithRange:NSMakeRange(idx, 2)]; <-- I switched out the range and decided to get the WHOLE string.
            CGSize s = [word sizeWithFont:self.font];
            if(drawPoint.x + s.width > rect.size.width) {
                drawPoint = CGPointMake(0, drawPoint.y + s.height);

            }