Closed jordanmaguire closed 10 years ago
Actually I'll investigate some more, might be another gem causing this issue.
For anyone running into a similar issue:
Looks like you should NOT instantiate objects as I was doing there. It will just return the same object every time. Makes sense.
You'll need to do the following, instead:
style :textField,
backgroundColor: UIColor.whiteColor,
leftView: lambda { UIView.alloc.initWithFrame(CGRectMake(0,0,20,44)) },
rightView: lambda { UIView.alloc.initWithFrame(CGRectMake(0,0,20,44)) }
That way you get a new object every time, instead of the same one. That's why it was crashing out when I was changing the leftViewMode/rightViewMode on any views that used that style other than the first one.
Without lambda:
(main)> Controller.current.view.nameField.leftView
=> #<UIView:0x94cc2b0>
(main)> Controller.current.view.emailField.leftView
=> #<UIView:0x94cc2b0>
With lambda:
(main)> Controller.current.view.emailField.leftView
=> #<UIView:0xa9889b0>
(main)> Controller.current.view.nameField.leftView
=> #<UIView:0xa98b3b0>
Ah, yes, I'll document that lambda
support in the README, and point out that if you need to create an object, that's the way to do it.
If in my stylesheet I have something like:
and apply that to an instance of a UITextField, my app dies with no error. The REPL becomes unresponsive and I have to force the simulator to quit.
If I don't set the leftViewMode or rightViewMode in the styles, and just set them on the instance itself, it all works fine.
I'm using:
Easy enough to work around. However, seems like something weird must be happening behind the scenes given this is no different from any other assignment.