我有一张新的ViewController上的imageView的图片数组。我可以让我的pageControl显示点,但是当我滑动到下一张图片时,点不会动画。关于无法找到的我有什么想法吗?谢谢!
import UIKit
import GoogleMobileAds
class imageViewController: UIViewController,GADBannerViewDelegate, UIGestureRecognizerDelegate, UIScrollViewDelegate {
var bannerView: GADBannerView!
@IBOutlet weak var scrollView: UIScrollView!
@IBOutlet weak var myImageView: UIImageView!
@IBOutlet weak var pageControl: UIPageControl!
var passedImage : UIImage! = nil
var passedArray : [UIImage]!
var index = 0
override func viewDidLoad(){
super.viewDidLoad()
self.myImageView.image = passedArray.first
scrollView.minimumZoomScale = 1.0
scrollView.maximumZoomScale = 5.0
configurePageControl()
//---------ADS----------------
// In this case, we instantiate the banner with desired ad size.
bannerView = GADBannerView(adSize: kGADAdSizeBanner)
addBannerViewToView(bannerView)
}
func viewForZooming(in scrollView: UIScrollView) -> UIView? {
return myImageView
}
func configurePageControl() {
self.pageControl.numberOfPages = passedArray.count
self.pageControl.currentPage = 0
self.pageControl.pageIndicatorTintColor = UIColor.black
self.pageControl.currentPageIndicatorTintColor = UIColor.red
self.view.addSubview(pageControl)
}
@IBAction func pictureswipe(_ sender: Any) {
let pictureString = self.passedArray[index]
self.myImageView.image = pictureString
index = (index < passedArray.count-1) ? index+1 : 0
}
@IBAction func pictureswipeback(_ sender: Any) {
let pictureString = self.passedArray[index]
self.myImageView.image = pictureString
index = (index > passedArray.count+1) ? index-1 : 0
}
答案 0 :(得分:0)
您还需要使用新索引来更新pageControl
的{{1}},请尝试按以下方式更新currentPage
方法。
IBAction