Wednesday, September 2, 2026
HomeiOS Developmentios - How you can create a horizontal scrolling stackView of UIViews...

ios – How you can create a horizontal scrolling stackView of UIViews utilizing .Xib recordsdata

[ad_1]

I wish to create a horizontal scrolling stackView of UIViews utilizing .Xib recordsdata, Thus far I’ve created the .Xib storyboard in addition to the cocoaTouch class that goes together with it and am having bother setting it up since that is my first time working with .Xib recordsdata.

I would like the output to look one thing like this:
ScrollView Desired result

However once I run the app it throws this error: Terminating app attributable to uncaught exception 'NSUnknownKeyException', motive: '[<NSObject 0x6000029f13d0> setValue:forUndefinedKey:]: this class shouldn't be key worth coding-compliant for the important thing itemImage.' and I do not know why that is occurring since I am very unfamiliar with .Xib recordsdata.

I’ve set the file proprietor’s class to the WhatsHotTile class in addition to the view itself.

Right here is the WhatsHotTile class:

class WhatsHotTile: UIView {
    @IBOutlet weak var itemName: UILabel!
    @IBOutlet weak var itemImage: UIImageView!
}

And right here is the code the place I try to create the horizontal scrolling stackView:

for shoe in Sneakers {
        if shoe.trending == true {
            if let whatsHotTile = Bundle.primary.loadNibNamed("WhatsHotTile", proprietor: nil, choices: nil)!.first as? WhatsHotTile {
                whatsHotTile.itemName.textual content = shoe.identify
                whatsHotTile.itemImage.picture = shoe.picture
                whatsHotStackView.addArrangedSubview(whatsHotTile)
            }
        }
    }

Since that is my first time working with .Xib recordsdata might somebody clarify why this error is happening / the right way to repair it in addition to what is the correct approach to create .Xib recordsdata and use them inside your code, in that case that may be very a lot appreciated.

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments