0

i know there are a lot of posts on this already, but I've searched through them and nothing seems to be working for me.

so my app has one page that you can zoom on an image. That works perfectly fine. But when i try to navigate to the other page that has the weblink button on it... my app crashes.. Then if i disable the zoom feature on the image, the page with the web link button works.. and the app doesn't crash.. super confused. all of my outlets are linked properly.

import UIKit

class ViewController: UIViewController, UIScrollViewDelegate {
    @IBOutlet weak var scrollView: UIScrollView!
    @IBOutlet weak var imageView: UIImageView!

    override func viewDidLoad() {
        super.viewDidLoad()
       self.scrollView.minimumZoomScale = 1.0 //getting error here EXC_BAD_instruction
        self.scrollView.maximumZoomScale = 6.0
    }

    @IBAction func WebLink(_ sender: AnyObject) {
        if let url = URL(string: "https://xxxxxxxxxxxxxxxx") {
            UIApplication.shared.open(url, options: [:]) {
                boolean in
                // do something with the boolean
            }
        }    
    }

    func viewForZooming(in scrollView: UIScrollView) -> UIView? {
        return self.imageView
    }
}
Bista
  • 7,869
  • 3
  • 27
  • 55
  • Read through the duplicate and its answers. Your scroll view outlet isn't connected. – rmaddy Apr 14 '17 at 04:37
  • Thank you, how do I go about looking through the duplicate? Sorry i am new to StackOverflow. – james dick Apr 14 '17 at 04:44
  • Look at the top of your question. – rmaddy Apr 14 '17 at 04:51
  • Oh Jeeze haha thanks again – james dick Apr 14 '17 at 04:53
  • hello rmaddy, thank-you for all the help so far, I really really appreciate it.. I re-connected my scrollView, the code works great (zooming works perfect) until I type the code for the WebLink. Then I get the same exc_bad_instruction beside the scrollView.minimumZoomScale, even though I know that code works. I am starting to understand force unwrapping, but I am ignorant to how I could apply it to my scenario? Thankyou again. – james dick Apr 15 '17 at 17:02
  • is it by any chance because two separate view controllers are both on the same ViewController.swift? Is there a way to separate the code somehow? – james dick Apr 15 '17 at 17:08
  • You should post a new question about your new issue. – rmaddy Apr 16 '17 at 02:28
  • I found the solution: I think the code was "battling" with each other. So i made a new cocao for each view controller with swift and now my app runs perfect! Thanks again – james dick Apr 17 '17 at 16:53

0 Answers0