NappUI icon indicating copy to clipboard operation
NappUI copied to clipboard

[ios 7][label] App crash with text align and links

Open mantonaci opened this issue 11 years ago • 11 comments

If you set text align (in my case Ti.UI.TEXT_ALIGNMENT_CENTER) and more links app crash on iOS 7.

The application has crashed with an uncaught exception 'NSRangeException'. Reason: NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds

mantonaci avatar Oct 08 '13 15:10 mantonaci

You could please paste an example Label object which I can test? Also, to what type of view did you add it to(Window, View, etc)?

Cheers, Nikh.

On Tue, Oct 8, 2013 at 8:33 PM, Michele Antonaci [email protected] wrote:

If you set text align (in my case Ti.UI.TEXT_ALIGNMENT_CENTER) and more links app crash on iOS 7.

The application has crashed with an uncaught exception 'NSRangeException'. Reason: NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds

Reply to this email directly or view it on GitHub: https://github.com/viezel/NappUI/issues/22

dezinezync avatar Oct 09 '13 03:10 dezinezync

Below there is a snippet of code, in this example, the underline is not displayed.

I add it on a ScrollableView.

var string = "Cliccando su Salva, indichi di aver letto e accettato la Normative sulla privacy e le Condizioni d'uso.";
var privacyLabel = Ti.UI.createLabel({
    top : 10,
    width : 300,
    textAlign : Ti.UI.TEXT_ALIGNMENT_CENTER,
    font : {
        fontSize : 14
    },
    color : "#3C3C3C",
    text : string,
    attributedText : {
        text : string,

        attributes : [{
            text : "Condizioni d'uso.",
            color : "#fff",
            link : "http://demo.paybay.it/web/termini",
            underline : 1
        }],

        attributes : [{
            text : "Normative sulla privacy",
            color : "#fff",
            link : "http://demo.paybay.it/web/termini",
            underline : 1
        }]
    }
});

Regards, M

mantonaci avatar Oct 22 '13 17:10 mantonaci

Can you please try the following, by replacing your attributedText prop with this one?

attributedText : {
        text : string,

        attributes : [{
                text : "Condizioni d'uso.",
                color : "#fff",
                link : "http://demo.paybay.it/web/termini",
                underline : 1
            },{
                text : "Normative sulla privacy",
                color : "#fff",
                link : "http://demo.paybay.it/web/termini",
                underline : 1
            }
        ]
    }

Also, if possible, I'd recommend using the range property instead of the text property. You can use it like so:

            {
                range : [57,23],
                color : "#fff",
                link : "http://demo.paybay.it/web/termini",
                underline : 1
            }

dezinezync avatar Oct 23 '13 11:10 dezinezync

It's work, but for some reason sometimes crash. Below, the full stack trace:

The application has crashed with an uncaught exception 'NSRangeException'.
Reason:
NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds
Stack trace:

0   CoreFoundation                      0x2e84ef53 <redacted> + 130
1   libobjc.A.dylib                     0x38b766af objc_exception_throw + 38
2   CoreFoundation                      0x2e84ee95 <redacted> + 0
3   Foundation                          0x2f17111d <redacted> + 120
4   Foundation                          0x2f17108f <redacted> + 46
5   Passpartu                           0x0040e259 -[TiUILabel(Extend) touchesEnded:withEvent:] + 724
6   UIKit                               0x31147101 <redacted> + 232
7   UIKit                               0x30fb7e4b <redacted> + 5522
8   UIKit                               0x30fefc41 <redacted> + 772
9   UIKit                               0x30fef5e7 <redacted> + 666
10  UIKit                               0x30fc4a25 <redacted> + 196
11  UIKit                               0x30fc3221 <redacted> + 7096
12  CoreFoundation                      0x2e81a18b <redacted> + 14
13  CoreFoundation                      0x2e81965b <redacted> + 206
14  CoreFoundation                      0x2e817e4f <redacted> + 622
15  CoreFoundation                      0x2e782ce7 CFRunLoopRunSpecific + 522
16  CoreFoundation                      0x2e782acb CFRunLoopRunInMode + 106
17  GraphicsServices                    0x3345b283 GSEventRunModal + 138
18  UIKit                               0x31024a41 UIApplicationMain + 1136
19  Passpartu                           0x0003a19b main + 114
20  Passpartu                           0x000396f0 start + 40

2013-10-25 10:32:54.295 Passpartu[1968:60b] *** Terminating app due to uncaught exception 'NSRangeException', reason: 'NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds'

mantonaci avatar Oct 25 '13 08:10 mantonaci

Ah! Happens when you tap a link? This is a known bug and I'm trying to find a fix for this. 

Cheers, Nikh.

On Fri, Oct 25, 2013 at 2:09 PM, Michele Antonaci [email protected] wrote:

It's work, but for some reason sometimes crash. Below, the full stack trace:

The application has crashed with an uncaught exception 'NSRangeException'.
Reason:
NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds
Stack trace:
0   CoreFoundation                      0x2e84ef53 <redacted> + 130
1   libobjc.A.dylib                     0x38b766af objc_exception_throw + 38
2   CoreFoundation                      0x2e84ee95 <redacted> + 0
3   Foundation                          0x2f17111d <redacted> + 120
4   Foundation                          0x2f17108f <redacted> + 46
5   Passpartu                           0x0040e259 -[TiUILabel(Extend) touchesEnded:withEvent:] + 724
6   UIKit                               0x31147101 <redacted> + 232
7   UIKit                               0x30fb7e4b <redacted> + 5522
8   UIKit                               0x30fefc41 <redacted> + 772
9   UIKit                               0x30fef5e7 <redacted> + 666
10  UIKit                               0x30fc4a25 <redacted> + 196
11  UIKit                               0x30fc3221 <redacted> + 7096
12  CoreFoundation                      0x2e81a18b <redacted> + 14
13  CoreFoundation                      0x2e81965b <redacted> + 206
14  CoreFoundation                      0x2e817e4f <redacted> + 622
15  CoreFoundation                      0x2e782ce7 CFRunLoopRunSpecific + 522
16  CoreFoundation                      0x2e782acb CFRunLoopRunInMode + 106
17  GraphicsServices                    0x3345b283 GSEventRunModal + 138
18  UIKit                               0x31024a41 UIApplicationMain + 1136
19  Passpartu                           0x0003a19b main + 114
20  Passpartu                           0x000396f0 start + 40
2013-10-25 10:32:54.295 Passpartu[1968:60b] *** Terminating app due to uncaught exception 'NSRangeException', reason: 'NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds'

Reply to this email directly or view it on GitHub: https://github.com/viezel/NappUI/issues/22#issuecomment-27074026

dezinezync avatar Oct 25 '13 09:10 dezinezync

Even when i tap a label that haven't a link. Maybe, i found a work around by setting tocuhEnabled false on Label (if isn't a link).

Regards, Michele

mantonaci avatar Oct 25 '13 09:10 mantonaci

Having the same crashes when click events are on a label. Getting the same error as above.

'Terminating app due to uncaught exception 'NSRangeException', reason: 'NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds'

I'm using NappUI module to add drop shadow to a view in another window but still crashes on the label with the click event. But I guess NappUI takes over default titanium UI.

Anyway, hope this helps with figuring out a fix for this bug.

Thanks for an awesome module!

harrythree avatar Jun 25 '14 20:06 harrythree

@dezinezync should we remove this feature, since its supported by appcelerator now ?

viezel avatar Jun 30 '14 12:06 viezel

Yes please. I have another implementation in place which I shall release once stable in it's own repo. Thanks.

dezinezync avatar Jun 30 '14 12:06 dezinezync

try 1.2.3 https://github.com/viezel/NappUI/commit/52f46d04d204e025c184ce4e41d5b27177252f62

viezel avatar Jun 30 '14 14:06 viezel

Thanks for the update guys!

harrythree avatar Jun 30 '14 18:06 harrythree