last day (19 days later) » 

5:17 PM
2
A: Is it possible to create Custom Segue which transitions from right to left

Thom MorganTry this class RightToLeftSegue : UIStoryboardSegue { override func perform() { guard let window = UIApplication.sharedApplication().keyWindow else { return } window.rootViewController = sourceViewController sourceViewController.view.superview?.addSubview(desti...

 
Awesome! It works! I have one question. when animation happens it shows blank page before animation completes, in this case it turns black out for a while so I changed window.backgoundColor to white. But is there any way that I can show destinationViewController as normal segue does?
 
@Dave Not sure what your question is. So after the animation, destinationViewController is blank instead of what you wanted?
 
no, destinationViewController actually shows up after the animation is completed, but while animation happens it shows just blank page.
 
Okay try the updated code
And when you say right to left... Do you mean the destination view is to the right of the source view?
 
It didn't work.. But it's already good and close enough to my original thought. Thanks much for your help.
 
5:17 PM
@Dave Let me run the code on my desktop when I get the chance. I wrote that code by hand and Swift is a little tricky to code in when not in the Xcode environment
 
Great! Thanks much @ThomMorgan !
 
@Dave try it again now. Still have not run it through Xcode though
 
Actually when you use the segue from UITableView, it seems animation doesn't work. Do you have any idea why?
 
@Dave A UITableView is not a UIViewController you need to do the transition with a UITableViewController
 
I see. In my case it's UIViewController which contains UITableView so I think it should work in the way you wrote but it didn't.
 
5:17 PM
@Dave can you post the code? Are you adding the table view to the UIViewController's view object? And are you setting the dimensions of the table view or adding autolayout constraints? Append it as an edit to your question
 
class SampleVC: UIViewController, UITableViewDelegate, UITableViewDataSource { var tableView: UITableView! override func viewDidLoad() { tableView = UITableView(frame: CGRectMake(0, 0, self.view.frame.width, self.view.frame.height)) self.view.addSubview(tableView) tableView.delegate = self tableView.dataSource = self } ... func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { self.performSegueWithIdentifier("segueIdentifier", sender: self) } }
 
@Dave what do you mean by the animation does not work? If the table view has no cells in it, then you'll just see the transition to an empty table view
 
if I setup the segue to Push(not Custom) it just shows up animatedly. but when I set the segue to Custom(in this case RightToLeftSegue class) it shows up just no animation. just as if pushing VC with animation false. self.presentViewController(navigationController, animated: false, completion: nil)
 
try this file. it works for me. you need make sure your table view is a retained private variable or the animation will not occur
wait i just updated the file try it now
 

  last day (19 days later) »