colinta / teacup

This project has been sunset in favor of MotionKit
github.com/motion-kit/motion-kit
Other
602 stars 85 forks source link

how to set the UITextField delegate #26

Closed smartweb closed 12 years ago

smartweb commented 12 years ago

I write like this, but not work

style UITextField, text: '', backgroundColor: UIColor.whiteColor, width: 150, height: 30, delegate: self

def textFieldShoudReturn(textfield) textfield.resignFirstResponder true end

colinta commented 12 years ago

hmm, this code looks like it's pulling in a few directions... if you are just styling a view, you can use the Teacup::View#style method without using a stylesheet:

# in a view controller
@button = UIButton. buttonWithType(UIButtonTypeRoundedRect)
# use teacup style method
@button.style({
  text: '',
  backgroundColor: UIColor.whiteColor,
  width: 150,
  height: 30,
  delegate: self
})

...

def textFieldShoudReturn(textfield)
  textfield.resignFirstResponder
  true
end

Your call to style UITextField looks out of place - what is the value of self at that point?

colinta commented 12 years ago

closing, for lack of information. if you're still having trouble, let me or someone know!