How do I perform an auto-segue in Xcode 6 using Swift?

If your UI is laid out in a Storyboard, you can set an NSTimer in viewDidLoad of your first ViewController and then call performSegueWIthIdentifier when the timer fires: class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. let timer = Timer.scheduledTimer(interval: 8.0, … Read more

UISearchController persisting after segue

You can hide the searchController manually by setting the active property to false in prepareForSegue. Add the below code in prepareForSegue() searchController.active = false Alternatively, you should add the following line in viewDidLoad() to get the default behaviour definesPresentationContext = true From the documentation for definesPresentationContext A Boolean value that indicates whether this view controller’s … Read more

How to present view controller from right to left in iOS using Swift

It doesn’t matter if it is xib or storyboard that you are using. Normally, the right to left transition is used when you push a view controller into presentor’s UINavigiationController. UPDATE Added timing function kCAMediaTimingFunctionEaseInEaseOut Sample project with Swift 4 implementation added to GitHub Swift 3 & 4.2 let transition = CATransition() transition.duration = 0.5 … Read more

Programmatically go back to previous ViewController in Swift

Swift 3: If you want to go back to the previous view controller _ = navigationController?.popViewController(animated: true) If you want to go back to the root view controller _ = navigationController?.popToRootViewController(animated: true) If you are not using a navigation controller then pls use the below code. self.dismiss(animated: true, completion: nil) animation value you can set … Read more

iOS Segue – Left to Right –

This is how I achieve the effect without requiring a nav-controller. Try this instead: Swift 4: import UIKit class SegueFromLeft: UIStoryboardSegue { override func perform() { let src = self.source let dst = self.destination src.view.superview?.insertSubview(dst.view, aboveSubview: src.view) dst.view.transform = CGAffineTransform(translationX: -src.view.frame.size.width, y: 0) UIView.animate(withDuration: 0.25, delay: 0.0, options: .curveEaseInOut, animations: { dst.view.transform = CGAffineTransform(translationX: 0, … Read more

Swift: Pass UITableViewCell label to new ViewController

Passing data between two view controllers depends on how view controllers are linked to each other. If they are linked with segue you will need to use performSegueWithIdentifier method and override prepareForSegue method var valueToPass:String! func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) { println(“You selected cell #\(indexPath.row)!”) // Get Cell Label let indexPath = tableView.indexPathForSelectedRow(); let … Read more