collectionViewの画像インデックスを別のviewControllerに送信すると、画像の配列が表示されます。この画像はフルスクリーンで表示され、画像をスワイプする機能がありますが、スワイプの問題は ですそれは非常に高速です私はUIImageViewの時間を遅らせる必要がある画像の間でスワイプ画像がその問題の任意のソリューションを変更したとき?UIImageViewでの遅延時間
以下のコード:のviewDidLoad FUNC
var ImageIndex:Int = 0 // this is index image which i send it from previous view controller
var arrayOfUrlImageLarge:[String] = []// this array which contain all the url of images
オーバーライド(){
super.viewDidLoad()
ImageViewの= UIImageView(画像:UIImage(contentsOfFile:arrayOfUrlImageLarge [ImageIndexプロパティ]))
imageView.contentMode = UIViewContentMode.ScaleAspectFill
let swipeGestureRight = UISwipeGestureRecognizer(target: self, action: #selector(ShowImageViewController.swipe(_:)))
swipeGestureRight.direction = .Right
let swipeGestureLeft = UISwipeGestureRecognizer(target: self, action: #selector(ShowImageViewController.swipe(_:)))
swipeGestureLeft.direction = .Left
self.imageView.addGestureRecognizer(swipeGestureLeft)
self.imageView.addGestureRecognizer(swipeGestureRight)
}
funcスワイプ(ジェスチャー:UISwipeGestureRecognizer){
if gesture.direction == .Right {
if ImageIndex == 0 {
imageView.image = UIImage(data: NSData(contentsOfFile: arrayOfUrlImageLarge[ImageIndex])!)
}else {
ImageIndex = ImageIndex - 1
imageView.image = UIImage(data: NSData(contentsOfFile: arrayOfUrlImageLarge[ImageIndex])!)
}
}
if gesture.direction == .Left{
if ImageIndex >= arrayOfUrlImageLarge.count {
ImageIndex = arrayOfUrlImageLarge.count - 1
imageView.image = UIImage(data: NSData(contentsOfFile: arrayOfUrlImageLarge[ImageIndex])!)
}else {
ImageIndex = ImageIndex + 1
if ImageIndex >= arrayOfUrlImageLarge.count {
return
}
imageView.image = UIImage(data: NSData(contentsOfFile: arrayOfUrlImageLarge[ImageIndex])!)
}
}
}
あなたのスワイプ機能で、このコードを試すことができますか?あなたの
このメソッドをviewdidloadに入れていただきありがとうございますか? –
同じメソッドで試してください –
私はそれを試してみてください –