简体   繁体   中英

How can I do this with one segue?

I want to pass movies's data to another controller also pass another controller when progress is finished.Can I do this with one segue ?

class LoadingScreenViewController: UIViewController {

    var movies  = [Movie]()
    @IBOutlet weak var progress: UIProgressView!
    @IBOutlet weak var countLabel: UILabel!

    override  func viewDidLoad() 
    {
        NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: #selector(LoadingScreenViewController.updateProgress), userInfo: nil, repeats: true)
        progress.setProgress(0, animated: true)
    }

    func updateProgress () {
        if progress.progress != 1 {
            self.progress.progress += 2 / 10

        } else {   
            UIView.animateWithDuration(0.4, animations: {  () -> Void in

            })
            performSegueWithIdentifier("segue", sender:self)
            progress.hidden = true
            self.countLabel.hidden = true
        }
    }

    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) 
    {
        let controller : SearchViewController = segue.destinationViewController as! SearchViewController
        if  segue.identifier == "segue"{
            controller.model = movies
        }

    }
}

Do following:-

 extension UIViewController {
        func addSearchController() {
          let searchController = UISearchController(searchResultsController: nil)
            self.view.addSubview(searchController.searchBar)
        }


    }

Just call self.addSearchController() method in viewDidLoad method of required VC. No need to pass SearchController.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM