我正在关注本教程:https://www.youtube.com/watch?v=Vq71SPkJIus,但由于某种原因,模拟器中没有出现任何内容,也没有错误,它只是显示“线程 1:断点 1.1” ,这是一个错误吗?抱歉,我对此很陌生,不太确定
我检查了所有代码以确保其正确,但不确定该怎么做,或者我做错了什么
@IBOutlet weak var pageControl: UIPageControl!
@IBOutlet weak var slideScrollView: UIScrollView!
override func viewDidLoad() {
super.viewDidLoad()
slideScrollView.delegate = self
let slides:[Slide] = createSlides() //THREAD 1: BREAKPOINT 1.1
setupScrollView(slides: slides)
pageControl.numberOfPages = slides.count
pageControl.currentPage = 0
// Do any additional setup after loading the view, typically from a nib.
}
func createSlides() -> [Slide] {
let slide1:Slide = Bundle.main.loadNibNamed("Slide", owner: self, options: nil)?.first as! Slide
slide1.label.text = "Slide1"
let slide2:Slide = Bundle.main.loadNibNamed("Slide", owner: self, options: nil)?.first as! Slide
slide2.label.text = "Slide2"
return [slide1, slide2]
}
func setupScrollView(slides:[Slide]) {
slideScrollView.frame = CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.width)
slideScrollView.contentSize = CGSize(width: view.frame.width * CGFloat(slides.count), height: view.frame.height)
slideScrollView.isPagingEnabled = true
for i in 0 ..< slides.count {
slides[i].frame = CGRect(x: view.frame.width * CGFloat(i), y: 0, width: view.frame.width, height: view.frame.height)
slideScrollView.addSubview(slides[i])
}
}
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let pageIndex = round(scrollView.contentOffset.x/view.frame.width)
pageControl.currentPage = Int(pageIndex)
}