-2

I'm going to try to explain this as well as I can, so please bear with me.

I have a table view populated with cells, I am trying to make it so when the tableViewCell is pressed it opens a VC with the details of the object described by the cell. I thought I got it working, but I noticed that if you back out of the new VC back to page with the tableView then press another cell, it does a transition as though it was going to a new page, but it still shows the page with the table view until you touch the screen (anywhere)

I was told it may not be a good idea to initialize a new VC within the function as I have done below as it may cause an increase of memory use, but whenever I try to initialize it anywhere else I get nothing but errors. I'm genuinely stuck.

Please note that the reason why I'm not using the built in segue function xCode provides is because this is a custom animation, so any solution which does away with the custom animation will not work.

It's very frustrating to have something almost working, but then little details break it. Any recommendations are appreciated, Thank you (code below)

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    let exerciseDetailsVC = storyboard?.instantiateViewController(withIdentifier: "ExerciseDetailsVC") as! ExerciseDetailsVC
    exerciseDetailsVC.exerciseIndex = indexPath.row
    presentDetail(exerciseDetailsVC)
}

EDIT: Requested presentDetail function

 func presentDetail (_ viewControllerToPresent: UIViewController){
    let transition = CATransition()
    transition.duration = 0.2
    transition.type = CATransitionType.push
    transition.subtype = CATransitionSubtype.fromRight

    self.view.window?.layer.add(transition, forKey: kCATransition)

    present(viewControllerToPresent, animated: false, completion: nil)
}
AtulParmar
  • 4,358
  • 1
  • 24
  • 45
Carbanim
  • 27
  • 2
  • 8
  • We can't help if you don't show us the `presentDetail` method or tell us the exact problem you are having with your posted code. – rmaddy Mar 15 '19 at 04:13
  • try to present controller on cell click/pressed. –  Mar 15 '19 at 04:24
  • Possible duplicate of [Go to the ViewController by clicking on the TableView cell in swift](https://stackoverflow.com/questions/47819575/go-to-the-viewcontroller-by-clicking-on-the-tableview-cell-in-swift) – えるまる Mar 15 '19 at 04:40
  • @rmaddy updated – Carbanim Mar 15 '19 at 06:19

1 Answers1

0

The issue was, there is a bug currently with xCode which causes any tableViewCell with no selection type to freeze its animation. It requires another action (any action, including shaking phone) to un freeze. Solution found, and explained better here. Sorry I was not able to explain this well enough.

presentViewController:animated:YES view will not appear until user taps again

Carbanim
  • 27
  • 2
  • 8