为什么无法识别我的变量。它在第二个视图控制器上。
import UIKit
class PacksPage: UIViewController {
@IBOutlet weak var iCarouselView: iCarousel!
var imageArray = [ UIImage(named:"PeoplePack"),
UIImage(named:"MachineryPack"),
UIImage(named:"ArchitecturePack") ,
UIImage(named:"MoneyPack"),
UIImage(named:"AnimalPack"),
UIImage(named:"PrimitivePack") ,
UIImage(named:"GalacticPack") ]
//...
}
extension ViewController: iCarouselDelegate, iCarouselDataSource {
func numberOfitems(in carousel: iCarousel) —> Int {
return imageArray.count
}
}
答案 0 :(得分:1)
出现此错误的原因是该变量在ViewController上不存在。您可以创建PacksPage viewController的扩展。
答案 1 :(得分:1)
您应该使用
extension PacksPage: iCarouselDelegate, iCarouselDataSource
代替
extension ViewController: iCarouselDelegate, iCarouselDataSource
尝试一下并分享您的结果。