I am using segmentio pod for segment with image and text, I have added pod in project and added view in storyboard and assign Segmentio class name and import Segmentio.
Here how to add array of text and images in segmentio
i have tried like below:
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)
}
}
errors :
Consecutive declarations on a line must be separated by ';'
Missing argument labels 'title:image:selectedImage:' in call
Consecutive declarations on a line must be separated by ';'
I haven't used this pod, but I think SegmentioItem
isn't type array, it looks like item of array, try this for one item:
let tornadoItem1 = SegmentioItem(title: "Alert", image: UIImage(named: "img1"))
content.append(tornadoItem1)
This is not valid Swift. The part that says
segmentioView.setup(
content: [SegmentioItem],
style: SegmentioStyle,
options: SegmentioOptions?
)
is not valid. It looks like a combination of a function call and a function definition.
I can see that the documentation for Segmentio is not very clear and also includes this invalid code.
Correct usage could be something like this:
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
)
}
I do not know Segmentio so this might not be 100 % correct.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.