UILabel sizeToFit crashed when OS version is 11.2 and device's language is Japanese

213 Views Asked by At

I have a simple code as the follow

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 60, 60)];
label.text = @"アクアレア カベルネソーヴィニヨン";
label.font = [UIFont systemFontOfSize:11.0f];
label.numberOfLines = 0;
[label sizeToFit];

When I set the device's language to English, it worked normally.

But when I try to set the device's language to Japanese(日本語), it crashed with message

*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSCFString rangeOfCharacterFromSet:options:range:]: Range {14, 18446744073709551612} out of bounds; string length 19'

My OS version is iOS 11.2, how can I fix this problem?

1

There are 1 best solutions below

0
On

The issue is because of the line: [UIFont systemFontOfSize:11.0f]; Removing this code is working fine and the application is not crashing both the English and Japanese language.