I add a UIButton to a UIBarButtonItem, the using the SimpleView button builder and the UI::UIButtonBuilder.new.build(..) crashed.
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
I add a UIButton to a UIBarButtonItem, the using the SimpleView button builder and the UI::UIButtonBuilder.new.build(..) crashed.
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)
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)
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)