apploft / ExpandableLabel

A simple UILabel subclass that shows a tappable link if the content doesn't fit the specified number of lines
MIT License
464 stars 126 forks source link

Clicking on "More" doesn't work on larger iPhones #81

Open mrferris opened 4 years ago

mrferris commented 4 years ago

The expanding functionality is working great for me on an iPhone 7 and smaller.

On an iPhone 8, the expanding is only triggered if the user clicks toward the top of the "More" button, higher than a user would typically touch on a button.

On phones larger than that, such as the iPhone XS and 11, the "More" button doesn't work at all.

The ExpandableLabel instance in question is created in Storyboard. It has AutoLayout constraints set on it in Storyboard. Its delegate, numberOfLines, and text are set in Swift via an outlet. I have not changed the attributed text.

Any tips or thoughts would be appreciated.

mrferris commented 4 years ago

For anyone else finding this, I ended up forking this repo and modifying the check(touch: UITouch, etc....) function to do a simple "is this touch in the vicinity of the bottom right side of the UILabel?" check via the touch point coordinates and the label view's bounds. On master it uses the characterIndex() function which was behaving very wrong, and seems overly-complex to me.

I've come to the conclusion that this entire library should inherit from UITextView instead of UILabel, which would allow it to use the much simpler solution of a function handler assigned to an NSAttributedString.

Any thoughts still appreciated.

ttmdung203 commented 4 years ago

I have another issue like: Small device can't show "more" text. Finally, after read this library source code, I found this is calculated by frame, I have to re-set value of label in func layoutSubViews to make sure frame size is correct when I set value for label, and it works well. I guess we have the different issues, but the same reason. Please try it? Hope it helpful.

umairalisyn commented 4 years ago

And one more thing text is truncated from top when there is no "more" or "less" in the text. I think it has something to do with expanded and collapsed gets created. Any advice will be appreciated.

justdan0227 commented 3 years ago

Anyone get an update on it. ...More appears to be working however CLOSE OR LESS does not show up.