seanho / SimpleView

RubyMotion DSL for UIKit
MIT License
103 stars 10 forks source link

UIBarButtonItem with custom view using SimpleView crash #8

Open jjuliano opened 12 years ago

jjuliano commented 12 years ago

I add a UIButton to a UIBarButtonItem, the using the SimpleView button builder and the UI::UIButtonBuilder.new.build(..) crashed.

  1. This crashed @nav_add_button = UI::Layouts.setup(view) do button buttonType: UIButtonTypeCustom, width: 32, height: 32 do @view.setBackgroundImage(UIImage.imageNamed("normal.png"), forState:UIControlStateNormal) @view.setBackgroundImage(UIImage.imageNamed("clicked.png"), forState:UIControlStateHighlighted) @view.addTarget(self, action:'performAdd', forControlEvents:UIControlEventTouchUpInside) end end

    self.navigationItem.rightBarButtonItem = UIBarButtonItem.alloc.initWithCustomView(@nav_add_button)

  2. Crashed @nav_add_button = UI::UIButtonBuilder.new.build(UIButton, buttonType: UIButtonTypeCustom) @nav_add_button.setBackgroundImage(UIImage.imageNamed("normal.png"), forState:UIControlStateNormal) @nav_add_button.setBackgroundImage(UIImage.imageNamed("clicked.png"), forState:UIControlStateHighlighted) @nav_add_button.frame = [[0,0], [32, 32]] @nav_add_button.addTarget(self, action:'performAdd', forControlEvents:UIControlEventTouchUpInside)

    self.navigationItem.rightBarButtonItem = UIBarButtonItem.alloc.initWithCustomView(@nav_add_button)

  3. This works as expected

    @nav_add_button = UIButton.buttonWithType(UIButtonTypeCustom) @nav_add_button.setBackgroundImage(UIImage.imageNamed("normal.png"), forState:UIControlStateNormal) @nav_add_button.setBackgroundImage(UIImage.imageNamed("clicked.png"), forState:UIControlStateHighlighted) @nav_add_button.frame = [[0,0], [32, 32]] @nav_add_button.addTarget(self, action:'performAdd', forControlEvents:UIControlEventTouchUpInside)

    self.navigationItem.rightBarButtonItem = UIBarButtonItem.alloc.initWithCustomView(@nav_add_button)