1

I'm coding a sort of listing app:

Each list has a title and an array of words:

class List {

var title: String
var words: [String]

}

I'd like to create a third scene where I can display the first word in the middle-left of the screen. When the user makes a gesture (say swipe right), this first word gets pushed upwards, making room to display the next word. This should go on until the last word of the array hits the screen.

[EDITED] What I've done so far:

  1. I've created a new ViewController and called it PlayViewController.
  2. I've control-dragged from the "Play" button from ListViewController to PlayViewController to create a show segue (identifier: playGame).
  3. I've added to PlayViewControllera table view, a cell table view and put inside it a label wordLabel. I've created a new file called PlayTableViewCellto make sure I can reach the label inside the cell in PlayViewController
  4. I've passed the data from ListViewControllerto PlayViewControllerusing override func prepare(for segue: UIStoryboardSegue, sender: Any?). I check if (segue.identifier == "playGame")to make sure I'm sending the data to right view.
  5. I've implemented three functions in PlayViewControllerto display my list of words :
    • func numberOfSections(in tableView: UITableView) -> Int
    • func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
    • func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell

Regarding the animation, I'm not sure to be on the right path. A table view might not be best when dealing with moving animations. I could toggle the words from hidden to visible but could I move them? I need help here.

I'm new to Swift (started to code on Xmas day) and everything I've learned these past days comes from the Apple tutorial + these three threads.

Any help to code this last part of my first app would be highly appreciated :) Thanks!

DFATPUNK
  • 123
  • 1
  • 1
  • 12
  • I moved forward with toggling the visibility of the labels. It's not exactly what I wanted in the first place but that will do the trick for v1.0 :) If anyone wants to share an idea about a more advanced animation, you're welcome. Meanwhile, here's my answered thread about the labels display: https://stackoverflow.com/questions/54028309/how-to-toggle-visibility-with-the-uilabel-in-uitableviewcell – DFATPUNK Jan 03 '19 at 22:13

0 Answers0