Мое приложение отображает табличное представление, которое откроется и отобразит изображение на новом ViewController.Я могу отправить массив изображений на новый контроллер, но не могу понять, как провести пальцем, чтобы отобразить второе изображение, которое является частью отправленного массива.Мой код ниже:
var firstchoice: [UIImage] = [
UIImage(named: "Appa1")!,
UIImage(named: "Appa2")!
]
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
{
///Right way here
///You can easily manage using this
let Vc = self.storyboard?.instantiateViewController(withIdentifier: "imageViewController") as! imageViewController
///Here you have written four Animal names in Array
///So There is going to four case 0,1,2,3 and a default case
switch indexPath.row
{
case 0:
Vc.passedArray = firstchoice
self.navigationController?.pushViewController(Vc, animated: true)
break;
imageViewController code:
class imageViewController: UIViewController,GADBannerViewDelegate, UIGestureRecognizerDelegate, UIScrollViewDelegate {
var bannerView: GADBannerView!
@IBOutlet weak var scrollView: UIScrollView!
@IBOutlet weak var myImageView: UIImageView!
@IBAction func pictureSwipe(sender: UISwipeGestureRecognizer) {
let pictureString:String = self.passedArray[index]
self.myImageView.image = passedArray.first
index = (index < passedArray.count-1) ? index+1 : 0
}
var passedImage : UIImage! = nil
var passedArray : [UIImage]!
var index = 0
override func viewDidLoad(){
super.viewDidLoad()
self.myImageView.image = passedArray.first
self.navigationController?.navigationBar.isHidden = false
scrollView.minimumZoomScale = 1.0
scrollView.maximumZoomScale = 5.0