CMPopTipView
CMPopTipView copied to clipboard
Width of the popview can be larger than the frame with a long title
I have mentioned this behaviour earlier in https://github.com/chrismiles/CMPopTipView/issues/58, but I finally found the root cause.
I have used version 2.2.0, but unfortunately it changes the width of the popview in a negative way. Also the property maxWidth is ignored completely.
Examples:
Previous version:
Version 2.2.0:
On iPhone it's even worse:
old:
new:
<B>ROOT CAUSE</B> The code assumes that the title is always a single row. Of course it might contain of so much words, that they have to be defined over multiple rows.
I have solved this by:
- Replacing the lineBreakMode for all title related code snippets:
titleParagraphStyle.lineBreakMode = NSLineBreakByWordWrapping;
This occurs in lines: 260, 279, 296, 313, 435 and 452.
- Correcting the options for the text frame:
options:NSStringDrawingUsesLineFragmentOrigin
This occurs in lines: 299 and 438.
After these changes the view is shown as expected with a multi-line title.
Having the same problem. It looks like the title was never intended to be that long. It's line break mode is set to NSLineBreakByClipping. The problem occurs on line 458: if (titleSize.width > textSize.width) textSize.width = titleSize.width;
This sets the textSize width to the titleSize's width ignoring the maxWidth.
FYI your fix works for me as well. nice work!
Can you submit a pull request containing the fix (reference this issue) ?
I can confirm that this was solved in https://github.com/chrismiles/CMPopTipView/commit/175d089259abded5a7718c3a1e2d7941b0ff2549. Also the current version https://github.com/chrismiles/CMPopTipView/commit/aeda632dfac30247e9f1875c4e6fda7e783d8e65 works fine.
This issue can be closed.