我遇到错误
“ UIScrollView”类型的值?没有成员“ delagate”
我一直在youtube上关注本教程 https://www.youtube.com/watch?v=AgUubgI-ZjI&feature=share
我该如何解决?
@IBOutlet weak var pageControl:UIPageControl!
@IBOutlet weak var scrollView:UIScrollView!
var images: [String] = ["About","Fidget Balancer","Home"]
var frame = CGRect(x:0,y:0,width:0,height:0)
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
pageControl.numberOfPages = images.count
for index in 0..<images.count {
frame.origin.x = scrollView.frame.size.width * CGFloat(index)
frame.size = scrollView.frame.size
let imgView = UIImageView(frame: frame)
imgView.image = UIImage(named: images[index])
self.scrollView.addSubview(imgView)
}
scrollView.contentSize = CGSize(width: (scrollView.frame.size.width * CGFloat(images.count)), height: scrollView.frame.size.height)
scrollView.delagate = self
}
//Scrollview Method
// ==============================
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
var pageNumber = scrollView.contentOffset.x / scrollView.frame.size.width
pageControl.currentPage = Int (pageNumber)
}
答案 0 :(得分:0)
替换
scrollView.delagate = self
使用
scrollView.delegate = self
并确保您的班级符合UIScrollViewDelegate
答案 1 :(得分:0)