jverdi / JVFloatLabeledTextField

UITextField subclass with floating labels - inspired by Matt D. Smith's design: http://dribbble.com/shots/1254439--GIF-Mobile-Form-Interaction?list=users
MIT License
7.2k stars 731 forks source link

Problems with iOS 10.2 - infinity cycle #187

Closed ed8009 closed 3 years ago

ed8009 commented 6 years ago

I started on a real device, but the problem can be reproduced on the simulator (I tried with iphone 7 plus iOS 10.2). If you enter some text in the textView, then select the text and click "Select All". The application will be in an infinity cycle, called layoutSubviews.

I tried to fix the problem and added a custom class for the textView. I redefine the intrinsicContentSize, it works, but there are other difficulties. Tell me how to fix this problem. The test project was add into my repository: https://github.com/ed8009/textView-With-JVFloatLabeledTextView

The problem occurs when scrollEnabled = NO

ed8009 commented 6 years ago

I do not quite understand this code, but if I remove it, everything works fine:

if (!self.scrollEnabled && !CGSizeEqualToSize(self.bounds.size, [self intrinsicContentSize])) {
        [self invalidateIntrinsicContentSize];
    }
ed8009 commented 6 years ago

Solution:

if (!self.scrollEnabled && !CGSizeEqualToSize(self.bounds.size, [self intrinsicContentSize])) { [self layoutIfNeeded]; }