【发布时间】:2015-09-11 12:55:58
【问题描述】:
从过去几天开始,我正在尝试为以编程方式添加的 UIBarButtonItem 生成一个弹出框,但我无法成功。除此之外,我什至希望这个弹出框按顺序显示一些可点击的图像。以下是我如何以编程方式生成 UIBarButtonItem 的代码
func imagerendering(){
let barbuttonimage = UIImage(named: "app")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
let button1 = UIBarButtonItem(image: barbuttonimage, style: .Plain, target: self, action: nil)
self.navigationItem.leftBarButtonItem = button1
let attachButtonImage = UIImage(named: "icon-Attach")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
let attachButton = UIBarButtonItem(image: attachButtonImage, style: UIBarButtonItemStyle.Plain, target: self, action: nil)
self.navigationItem.setRightBarButtonItems([menuButton,attachButton], animated: true)
let fixedSpace:UIBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.FixedSpace, target: nil, action: nil)
fixedSpace.width = 5.0
self.navigationItem.rightBarButtonItems = [menuButton, fixedSpace, attachButton]
self.navigationController?.navigationBar.titleTextAttributes = [NSFontAttributeName:UIFont(name: "Avenir-Black", size: 16)!]
}
我已经在图片中展示了我想要的输出,作为下面的链接。请通过它,让我知道我想要的是否可能。
【问题讨论】:
-
是的,这是可能的。告诉我你能做一个简单的弹出框吗?
-
@iRealMe 我知道如何使用情节提要来呈现它,但我不确定如何以编程方式呈现它……你浏览过图像吗……?在弹出窗口中,我需要按顺序呈现图像,而这些图像又将有一个动作来执行
-
好的..这些图片来自哪里?
-
就像在 tableview 中一样,我们可以正确添加图像 .. 并对其进行编程。以同样的方式,我想这样做请通过链接 [示例图片] (s16.postimg.org/4zri7xc6d/exampleimage.png)
标签: ios swift uitableview uibarbuttonitem uipopovercontroller