CMPopTipView icon indicating copy to clipboard operation
CMPopTipView copied to clipboard

Width of the popview can be larger than the frame with a long title

Open funnel20 opened this issue 10 years ago • 3 comments

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: 1

Version 2.2.0: 2

On iPhone it's even worse: old: 3

new: 4

<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:

  1. Replacing the lineBreakMode for all title related code snippets:
titleParagraphStyle.lineBreakMode = NSLineBreakByWordWrapping;

This occurs in lines: 260, 279, 296, 313, 435 and 452.

  1. 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.

funnel20 avatar Dec 02 '14 14:12 funnel20

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!

ogoldfinger avatar Jan 28 '15 01:01 ogoldfinger

Can you submit a pull request containing the fix (reference this issue) ?

chrismiles avatar Jan 30 '15 00:01 chrismiles

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.

funnel20 avatar Mar 12 '15 13:03 funnel20