Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message with Chinese characters is cut when it is displayed in the table cell. #23

Open
chenweiyj opened this issue Aug 3, 2014 · 3 comments

Comments

@chenweiyj
Copy link

Hi all,

I send a message of Chinese characters more than 16 words in utf8. It is fine to see that the whole string is recorded in the database. However, when it is displayed in the table cell, only one line is displayed, all others is cut and is not displayed any more. I think it is a bug; however, I cannot find where the problem is.

Anyone can help me? Thank you very much!

@yang0013
Copy link

yang0013 commented Aug 7, 2014

I found the same problem.It's in the file "NSString+Calculation.m"
change the function as following ,it works fine

  • (CGSize)usedSizeForMaxWidth:(CGFloat)width withFont:(UIFont *)font
    {
    CGRect stringRect = [self boundingRectWithSize:CGSizeMake(width, CGFLOAT_MAX)
    options:(NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading)
    attributes:@{ NSFontAttributeName : font }
    context:nil];

    CGSize stringSize = CGRectIntegral(stringRect).size;

    return stringSize;
    }
    The above code is copy from JSQMessage

@waynewgl
Copy link

waynewgl commented Sep 2, 2014

the solution above couldn't solve the problem perfectly, last few characters were cut still when you enter words, like, more than four lines. is this common issue?

@Antairez
Copy link

Antairez commented Sep 7, 2014

By using solution suggested by @yang0013, I can confirm that it works for really really long messages (say, more than 10 lines). But when the message is just about over 4 lines, the problem persists, and some of the characters were not shown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants