Wednesday, January 13, 2016

Day 58

Custom Cells and Multiple Views


Today I finished the iOS Intermediate chapter. We learned this past week about table view cells. What if we want different labels for every single view cells? We then have a custom cell. The only difference is to have a custom cell file (or put it in your view controller with the appropriate class) that contains all the features you have on the view. I also learned today how to segue into other views and why delegates are now so important. 

We can connect two different view controllers via navigation controllers. But there are multiple ways to present new controllers. We do everything modally because this allows us to go back as well as go forward to other controllers whereas if we do just show, we can only move back. There are two things that we need when we move between view controllers: 
  1. Protocols that contains delegates
  2. Prepare/perform segue functions
We link our button that starts the segue and we write the perform segue method. After which, we have a prepare for segue override function. The prepare segue function is very important because we decide there which view we are going to go to and how, as well as which delegate functions or variables we're passing over into the second view. 

I really struggled with this concept of passing variables and functions through the prepare segue. In the beginning I couldn't connect them but I realized that they must be declared in the second controller.


No comments:

Post a Comment