ios – How to make a UIButton on A View.xib with swipe feature go to a ViewController


I’ve created a View.xib file that contains a UILabel and UIButton. And a ViewController that contains a page control swipe feature that references the UILabel and UIButton. I’ve created 3 pages for this feature, when I swipe UILabel displays different text on each page. How do I do this for the UILabel to go to different ViewControllers for each of the 3 pages.

View.swift code

class View: UIView {

@IBOutlet weak var title: UILabel!
@IBOutlet weak var propertyInfo: UIButton!

ViewController code

var pages : [View] {
    
    get {
let page1: View = Bundle.main.loadNibNamed("View", owner: self, options: nil)?.first as! View
        page1.title.text = "ApartmentA3"
let page2: View = Bundle.main.loadNibNamed("View", owner: self, options: nil)?.first as! View
        page2.title.text = "APARTMENT A4"
let page3: View = Bundle.main.loadNibNamed("View", owner: self, options: nil)?.first as! View
        page3.title.text = "APARTMENT A5"
return [page1, page2, page3]
    }

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img