ios - 如何快速在 Segmentio 中添加文本和图像数组
问题描述
我正在使用segmentio pod 来分割图像和文本,我在项目中添加了 pod 并在情节提要中添加了视图,并分配了 Segmentio 类名并导入了 Segmentio。
这里如何在segmentio中添加文本和图像数组
我试过如下:
import UIKit
import Segmentio
class EventsDashboardViewController: UIViewController {
@IBOutlet weak var segmentioView: Segmentio!
//var swipeMenuArray: NSMutableArray = []
var content = [SegmentioItem]()
override func viewDidLoad() {
super.viewDidLoad()
segmentioView.setup(
content: [SegmentioItem],
style: SegmentioStyle,
options: SegmentioOptions?
)
let tornadoItem = SegmentioItem(
(title: "Alert",
image: UIImage(named: "img1")),
(title: "Message",
image: UIImage(named: "img2")),
(title: "Stared",
image: UIImage(named: "img3"))
)
content.append(tornadoItem)
}
}
错误:
一行中的连续声明必须用';'分隔
调用中缺少参数标签“title:image:selectedImage:”
一行中的连续声明必须用';'分隔
解决方案
这不是有效的 Swift。说的部分
segmentioView.setup(
content: [SegmentioItem],
style: SegmentioStyle,
options: SegmentioOptions?
)
无效。它看起来像是函数调用和函数定义的组合。
我可以看到 Segmentio 的文档不是很清楚,并且还包含此无效代码。
正确的用法可能是这样的:
override func viewDidLoad() {
super.viewDidLoad()
content.append(SegmentioItem(title: "Alert", image: UIImage(named: "img1"))
content.append(SegmentioItem(title: "Message", image: UIImage(named: "img2"))
content.append(SegmentioItem(title: "Stared", image: UIImage(named: "img3"))
segmentioView.setup(
content: content,
style: .imageBeforeLabel,
options: nil
)
}
我不知道 Segmentio,所以这可能不是 100% 正确的。
推荐阅读
- java - CN1:滚动在 MultiButton 上不起作用
- node.js - 我无法切换 node.js 版本
- ios - Sprite 套件中的 SKShapeNode 碰撞检测未检测到碰撞
- java - 如何在 Java 中修复“SAAJ0537:无效的内容类型”
- postgresql - How to run native postgres query using spring-data-jpa
- sas - 在 Proc SQL 中使用 IIF
- apache - https 站点中的 MOZILLA_PKIX_ERROR_SELF_SIGNED_CERT HSTS
- emacs - 全局键的奇怪行为
- sql - Query to determine cumulative changes to records
- linux - Trying to read a serial number into a variable to compare to a list of serial numbers to rename a machine