Storyboards Tutorial in iOS 9: Part 1

OH never mind, I named my cell identifier as “players” instead of “PlayerCell”.

I am finished the part 1 tutorial. Now it says that PlayerCell us an undeclared identifier.
` override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath)
→ UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier(“PlayerCell”, forIndexPath: indexPath)
as! PlayerCell

        let player = players[indexPath.row] as Player
        cell.player = player
        return cell
}

`

@sg14_96 - as long as your cell in the storyboard has the correct custom class PlayerCell and the identifier set to PlayerCell, it should work.

If not, download the sample code provided and check what differences you have. I just checked the download, and it does work in Xcode 7.3

1 Like

OK I figured it out, it turns out that when I created the new swift files; instead of being named PlayersViewController, it got named PlayersViewControllerTableViewController. And when I tried to change it back to what you have in your code, it told me it:
2016-07-12 11:36:29.659 Ratings[21719:3636749] Unknown class _TtC7Ratings40PlayersViewControllerTableViewController in Interface Builder file.

And it would not build the cells. But I got it working again!
Thanks Caroline !

1 Like

Hi,

I don’t see the tab bar items simulated on the storyboard eventhough they appear when theyre running in the simulator. Is there a fix for this??

Thanks

@davidm71 - What have you tried?

The sample final project has this for the tab bar items:

(This is a screenshot of the Tab Bar Controller in the storyboard)

Hi,

I found a solution but first let me describe the bug. When you try to create a basic tab bar you don’t see any tab bar item default icons in the storyboard and instead just see a grey bar. The fix is to go into identity inspector for the tab bar item and just press a space into the name of the file for the tab bar icon location. After that it becomes visible. Curious that the preset tab bar project sets you up with actual icons. Thanks

Hi Caroline,

Hope you are doing good!

I have a query for you. You are creating the cell on the storyboard. What’s the main benefit to create the table cell directly on storyboard? And it loads into the memory on the time of Storyboard loads or not. Please clear to me.

Thanks!

Hi @nitink - For me the main benefit in creating the table cell in the storyboard is so that I can design and lay it out visually. If I create it in code, I find it much harder to get the layout right and also harder to change later on if I have to.

I would expect the definition of the cell is loaded into memory when the Storyboard loads. However, the actual cell’s data will only be created when there is data to put in it. There will be a cell created for every item of data presented to the table.

Hello Caroline.
First of all - thank you a lot for your tutorials. Great thanks.

Could you please help me on this one?
My tabBar leads to View controller, that contains TableView. Each cell leads to another View controller with Table view.

And I’m having troubles relating final view controller to my initial tab bar. So how do I relate final view Controller with tabBars?
Trick “Editor\Embed In\Navigation Controller” wouldn’t do much help, as it storyBoard element Before my TableView.

Thank you in advance.

@lexx0 - I’m not sure I understand.

If your top view controller is embedded in a navigation controller, and you are “pushing” sub-view controllers, the navigation bar should have a “Back” button so you can go back a level at a time.

Or you can pop to root view controller.

Okay,

Now it’s clear to me. But one more question.

As you know, a storyboard is a single file. So how it’s load into memory. Suppose I have 5 UIViewController on it. Are these load into memory at that moment OR will load at the time of UIViewContrller usage? I mean one by one.

Hope, my question is clear to you.

Thanks!

@nitink - UIViewControllers will be loaded into memory at the appropriate time. When they are closed, after deinit, the memory may be unloaded, but the system determines that. Cacheing goes on automatically behind the scenes.

Okay, that’s great.

Thanks!

Hello, I am trying to make a list of favorites using your tutorial. And I can not. I have a tableview that must receive data from different views (label and image). And that this list is always filled in with the choices of the user. Would you have any advice or example that could help me. Thank you

@fabrice - I would suggest to make your table view’s data source a single array. You can merge the data from your different views into that single array.

This makes creating the end table view a simple process.

Hello, thank you for your answer but do not understand your answer. Can you be oriented towards an example more in line with my request

@fabrice I may have misunderstood your question. I thought you were trying to merge data into a table.

Can you explain further?

Good evening, actually I try to make a list of favorites, not in the same way as a todo list or the add button is een top of view. I have 10 views with the description of a place. On each view I have a button add to favorites. When I click the button an image and a label must be sent to a view table that will be my favorites list. Then when the user goes to the application he can open this list and select the line that interests him and it will send it to the detailed view from which this line of favorites has been created. I am looking for examples or help to create this list of favorites. thank you

@fabrice - I don’t know any actual examples, but if I understand what you are talking about, it should be fairly simple.

For example you could have a class or struct called Favorite consisting of two elements - image , label.

You have an array favorites: [Favorite] to which you add all your favorites as the user presses the favorite button.

You have a table view which is a simple table view showing a list of favorites. This would be the same as in this tutorial’s list of players.

When the user selects a row in the table, just as when you select a player in part 2 of this tutorial and show the player’s details, you show the Favorite. You call a new view controller (not as in this tutorial a grouped table), which shows the image and the label from the selected Favorite.

In fact it seems very similar to this tutorial. Just structure your data as I have described above. This data structure is essentially the same as a list of players going to one player’s detail. Yours is a list of favorites going to one favorite’s detail.