I'm coding a sort of listing app:
- my first view a Table View Controller with all the lists created called
ListTableViewController
- my second is a View Controller to create or edit an existing list called
ListViewController
.
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:
- I've created a new ViewController and called it
PlayViewController
. - I've control-dragged from the "Play" button from
ListViewController
toPlayViewController
to create a show segue (identifier:playGame
). - I've added to
PlayViewController
a table view, a cell table view and put inside it a labelwordLabel
. I've created a new file calledPlayTableViewCell
to make sure I can reach the label inside the cell inPlayViewController
- I've passed the data from
ListViewController
toPlayViewController
usingoverride func prepare(for segue: UIStoryboardSegue, sender: Any?)
. I checkif (segue.identifier == "playGame")
to make sure I'm sending the data to right view. - I've implemented three functions in
PlayViewController
to 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!