Merge pull request #527 from clearsightstudio/bugfix/524

Fixes issue 524.
This commit is contained in:
Jamon Holmgren
2014-08-12 12:35:55 -07:00
3 changed files with 29 additions and 4 deletions

View File

@@ -0,0 +1,15 @@
class UIImageTitleScreen < PM::Screen
attr_accessor :button_was_triggered
title_image UIImage.imageNamed('test.png')
def will_appear
self.button_was_triggered = false
add UILabel.alloc.initWithFrame([[ 10, 10 ], [ 300, 40 ]]),
text: "Label Here"
end
def triggered_button
self.button_was_triggered = true
end
end

View File

@@ -27,7 +27,7 @@ module ProMotion
case self.class.title_type
when :text then self.title = self.class.title
when :view then self.navigationItem.titleView = self.class.title
when :image then self.navigationItem.titleView = UIImageView.alloc.initWithImage(UIImage.imageNamed(self.class.title))
when :image then self.navigationItem.titleView = UIImageView.alloc.initWithImage(self.class.title)
else
PM.logger.warn("title expects string, UIView, or UIImage, but #{self.class.title.class.to_s} given.")
end
@@ -178,7 +178,7 @@ module ProMotion
end
def title_image(t)
@title = t
@title = t.is_a?(UIImage) ? t : UIImage.imageNamed(t)
@title_type = :image
end

View File

@@ -1,9 +1,19 @@
describe "ProMotion::Screen UIImage title" do
describe "ProMotion::Screen UIImage string title" do
def controller
@controller = ImageTitleScreen.new(nav_bar: true)
end
it "should allow an image title" do
it "should allow an image title as a String" do
controller.navigationItem.titleView.should.be.kind_of UIImageView
end
end
describe "ProMotion::Screen UIImage title" do
def controller
@controller = UIImageTitleScreen.new(nav_bar: true)
end
it "should allow an image title as a UIImage" do
controller.navigationItem.titleView.should.be.kind_of UIImageView
end
end