【发布时间】:2016-10-25 02:07:11
【问题描述】:
我正在使用 JSQmessageViewController 并尝试以编程方式在导航栏上添加“返回”按钮和用户图像。我正在使用以下代码。运行后,没有“返回”按钮或图像。附上模拟器截图。我用普通的 UIViewController 测试了这些代码,它们工作正常。
我可以知道他们为什么不使用 JSQmessageViewController 吗?我应该怎么做才能在导航栏上添加“返回”按钮和图像?非常感谢!
let navigationBar = UINavigationBar(frame: CGRectMake(0, 0, self.view.frame.size.width, 64))
navigationBar.backgroundColor = UIColor.whiteColor()
navigationBar.delegate = self;
let navigationItem = UINavigationItem()
navigationItem.title = strValue
let leftButton = UIBarButtonItem(title: "Back", style: UIBarButtonItemStyle.Plain, target: self, action: "back:")
self.navigationItem.leftBarButtonItem = leftButton
let imgButton = UIButton()
imgButton.setImage(image, forState: .Normal)
imgButton.addTarget(self, action: "EditProfile:", forControlEvents: UIControlEvents.TouchDown)
imgButton.frame = CGRectMake(self.view.frame.width - 60, 0, 41, self.view.frame.height)
var rightButton = UIBarButtonItem(customView: imgButton)
self.navigationItem.rightBarButtonItem = rightButton
navigationBar.items = [navigationItem]
self.view.addSubview(navigationBar)
}
【问题讨论】:
-
我没有看到所附的屏幕截图。
标签: uinavigationbar uinavigationitem jsqmessagesviewcontroller