SimpleView icon indicating copy to clipboard operation
SimpleView copied to clipboard

UIBarButtonItem with custom view using SimpleView crash

Open jjuliano opened this issue 13 years ago • 0 comments

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)

jjuliano avatar Jul 19 '12 20:07 jjuliano