Midwest Dev Chat

MidwestDevChat.com

  • The newest 15 messages in the super-cool #ios channel.

  • 11/02 14:57:05 Jamison: App Store Connect API is live: https://developer.apple.com/app-store-connect/api/
  • 11/06 09:10:38 Jamison: https://blog.sentry.io/2017/04/11/ios-symbolica...
  • 11/09 12:41:40 Jamison: Today I learned that Xcode provides a launch option you can pass to debug an autolayout feedback loop:
    I also learned that you can cause an autolayout feedback loop by giving a `UITextField` an empty dictionary of text attributes: ```class ViewController: UIViewController {
        @IBOutlet weak var textField: UITextField!
    
        override func viewDidLoad() {
            super.viewDidLoad()
            textField.defaultTextAttributes = [:]
        }
    }
    
  • 11/09 13:19:58 Renae: I am very interested in both of those comments. I am guessing you figured out #1 to debug #2?
  • 11/09 13:21:02 Renae: It's strange that a viewDidLoad could cause layout loop. It always presented as "the function that only gets called on init" in VC discussions
  • 11/09 13:25:20 Jamison: Yes, that was the order of things. I had this view that was working just fine, then I added the custom appearance logic and the UI froze. `viewDidLoad()` is only called once, even in this code
  • 11/09 13:27:15 Jamison:
            super.viewDidLoad()
            textField.defaultTextAttributes = [NSAttributedString.Key.font: someFont]
        }
  • 11/09 13:27:33 Jamison: With _that_ code, everything works fine and there is no infinite layout loop
  • 11/09 13:29:14 Jamison: The problem was that UIKit was not prepared to lay out a UITextField with no text attributes, and I had a bug in the part of my styling system that generates text attribute dictionaries
  • 11/09 13:40:05 Rutha: Interesting. TIL about `UIViewLayoutFeedbackLoopDebuggingThreshold`. Also seems like a UIKit bug that empty text attributes would cause the loop, a crash i could see
  • 11/09 13:40:52 Jamison: Yeah, I think a crash would be more appropriate
  • 11/09 13:41:24 Jamison: I'll file a radar wastebasket
  • 11/09 13:42:21 Renae: Good o' apple and there Cocoa bugs. Let me hunt down a workout I have hiding in some code
  • 11/09 13:47:34 Renae: Can't find the code, but this is the related SO discussion https://stackoverflow.com/questions/19049917/ui...
  • *Usernames have been changed to protect the innocent.
We're currently 1111 members strong. Join us!
Request Invite

Check out all the cool channels!

Join the conversation!