1 00:00:00,490 --> 00:00:01,710 So well come back again. 2 00:00:01,720 --> 00:00:07,360 This is actually an exercise on what you're supposed to be doing is you have to make a school of you 3 00:00:07,390 --> 00:00:09,140 with a page control. 4 00:00:09,340 --> 00:00:17,280 So essentially you have to find a way to control the page controller's place with the scroll of use 5 00:00:17,310 --> 00:00:23,190 Koren's place of the scroll as well as the opposite of it controlling the scroll do you. 6 00:00:23,310 --> 00:00:25,780 When they use the taps on the page control. 7 00:00:26,020 --> 00:00:31,420 Now I would encourage you to do this on your own and if you felt like you needed some help you can look 8 00:00:31,420 --> 00:00:32,990 at my solution as well. 9 00:00:33,050 --> 00:00:35,820 Pushover Let's start in just a few seconds. 10 00:00:35,920 --> 00:00:41,160 If you're still wondering how that relationship should be between the page controller and a scroll if 11 00:00:41,170 --> 00:00:48,460 you just look at the main view of your iPhone or your simulator when you scroll one whole page it goes 12 00:00:48,460 --> 00:00:49,590 for the next one. 13 00:00:49,630 --> 00:00:52,870 I mean you type on the page controller it just crawls the whole view. 14 00:00:52,870 --> 00:00:56,380 One more page to this site that you have typed on. 15 00:00:56,380 --> 00:01:00,570 So this relationship is what you have to be doing in this exercise. 16 00:01:00,670 --> 00:01:06,340 So I'm going to start in a few seconds if you want to compose the video now and then hopefully we'll 17 00:01:06,340 --> 00:01:07,150 get there. 18 00:01:07,150 --> 00:01:09,030 And if you want to look at my solution as well. 19 00:01:13,090 --> 00:01:13,520 OK. 20 00:01:13,550 --> 00:01:14,440 Let's get started. 21 00:01:14,450 --> 00:01:20,900 I'm going to go to school and in yeah I'm going to start a new application called the scroll of view 22 00:01:21,520 --> 00:01:26,410 page control of and you might ask for a view with page control. 23 00:01:26,430 --> 00:01:33,550 I'm going ahead to the storyboard and I will have to make a scroll for you as well as a page controller. 24 00:01:33,570 --> 00:01:36,050 So you are a page control. 25 00:01:36,230 --> 00:01:40,690 I'm going to place it maybe around here make it much wider. 26 00:01:40,690 --> 00:01:41,960 I'm going to give it a thank you. 27 00:01:42,000 --> 00:01:43,800 Color of black. 28 00:01:43,800 --> 00:01:45,750 So it's quite visible. 29 00:01:45,930 --> 00:01:49,390 Then I'm going to are this cruel of you. 30 00:01:49,850 --> 00:01:54,720 I will place it right under the page controller but place it here. 31 00:01:54,960 --> 00:01:57,090 You can cover the entire screen. 32 00:01:57,090 --> 00:02:00,790 I'm not doing that just to show you that you don't have to. 33 00:02:01,170 --> 00:02:04,430 So the page can do it I'm going to have to add some constraints for it. 34 00:02:04,440 --> 00:02:11,670 It has a constant from the top a leading constraint and a trailing constraint that they have to reset 35 00:02:11,670 --> 00:02:12,890 it to be zero. 36 00:02:12,990 --> 00:02:18,080 So it's trailing will be also a constant value of zero. 37 00:02:18,300 --> 00:02:21,120 So it covers the entire width of the screen. 38 00:02:21,260 --> 00:02:25,660 And if you can actually add it as well so it has equal weights. 39 00:02:25,680 --> 00:02:28,410 The view was a super view. 40 00:02:28,500 --> 00:02:33,760 Now my school view I'm going to make it a background that is a light very great. 41 00:02:33,930 --> 00:02:41,070 It has a kind of strange to the page control the vertical spacing and that the value is actually going 42 00:02:41,070 --> 00:02:42,540 to make sure it is zero. 43 00:02:42,780 --> 00:02:43,530 It is. 44 00:02:43,530 --> 00:02:52,190 So it has no constant value then it has a leading space a trailing space. 45 00:02:52,380 --> 00:03:00,170 It has an equal right to the actual view and the one that I have an aspect ratio on it that says As 46 00:03:00,180 --> 00:03:05,040 find that aspect ratio it says the height of the scroll view. 47 00:03:05,050 --> 00:03:06,610 So I'm going to have to reverse it. 48 00:03:06,700 --> 00:03:12,080 The height of a school equals the Vittal feet in a one to one. 49 00:03:12,790 --> 00:03:16,760 So again you don't have to necessarily follow these instructions. 50 00:03:16,760 --> 00:03:18,560 These are just the settings I'm using. 51 00:03:18,700 --> 00:03:24,230 I'm going to have a square shaped scroll view and I want to be right underneath the page control there 52 00:03:24,540 --> 00:03:25,900 are a lot of thumbs. 53 00:03:25,900 --> 00:03:30,790 Actually most often the page one too is actually at the bottom of this global view but all of these 54 00:03:30,790 --> 00:03:33,010 things you can just decide on your own. 55 00:03:33,040 --> 00:03:37,980 So the next thing is we need to have a view that is a container of view that is the view that we to 56 00:03:37,990 --> 00:03:40,420 put everything else in sight. 57 00:03:40,630 --> 00:03:48,300 So let's go ahead and say I have a of view and I went at that view and place it right there. 58 00:03:50,270 --> 00:03:50,990 On here. 59 00:03:50,990 --> 00:03:51,880 Exactly. 60 00:03:51,910 --> 00:03:58,430 And if you recall the last time we had to do a constraint that would automatically set the vet of this 61 00:03:58,470 --> 00:04:05,750 you to be one fifth of the scroll view or essentially making the scroll of you accommodate for five 62 00:04:05,750 --> 00:04:06,730 of these. 63 00:04:06,800 --> 00:04:09,020 This time I'm going to do things a little differently. 64 00:04:09,020 --> 00:04:17,900 So it's going here and I'm going to say I have a leading space constraint so that's something that they 65 00:04:17,900 --> 00:04:18,800 have to have. 66 00:04:18,920 --> 00:04:21,650 I'm going to have a top space constraint. 67 00:04:21,650 --> 00:04:25,360 That's something that they have to have and when I have them one. 68 00:04:25,450 --> 00:04:29,520 So that's again something we should have if you read the appels documentation. 69 00:04:29,510 --> 00:04:34,850 They specifically suggest that for a school of use you add your constraints from left to right and from 70 00:04:34,850 --> 00:04:36,150 top to bottom. 71 00:04:36,200 --> 00:04:38,020 So that's what they have done so far. 72 00:04:38,030 --> 00:04:41,120 I have a top concern I have to buy them first thing. 73 00:04:41,150 --> 00:04:42,960 I have a leading constraint. 74 00:04:42,980 --> 00:04:48,530 I'm going to go ahead and say Give me a trailing constraint and the trailing constantly would be just 75 00:04:48,530 --> 00:04:54,170 like the last time Super of view equals the view trailing the stand the constant of it is zero. 76 00:04:54,170 --> 00:04:56,090 Just like the last time it was. 77 00:04:56,210 --> 00:05:01,900 Then the next thing I'm going to do is this I'm going to go ahead and say my view compared to the scroll 78 00:05:01,910 --> 00:05:02,370 view. 79 00:05:02,540 --> 00:05:05,510 It always has an equal height to the height. 80 00:05:05,520 --> 00:05:07,730 Not exactly the same at all times. 81 00:05:07,910 --> 00:05:12,170 And then I'm going to go ahead and say and this is the part that is different than what you have done 82 00:05:12,170 --> 00:05:13,260 last time. 83 00:05:13,310 --> 00:05:18,620 Just to remind you the last time we actually added the constraint that set our view against the school 84 00:05:18,620 --> 00:05:22,200 view has a constraint that makes it five times larger. 85 00:05:22,220 --> 00:05:26,880 Now this time I'm going to say my view as a vet can sustain itself. 86 00:05:27,050 --> 00:05:34,100 So it's a it is always said Art at the moment 375 and you will see why am I doing this because I want 87 00:05:34,100 --> 00:05:40,070 to use this feet inside my programming interface and change it on the fly. 88 00:05:40,100 --> 00:05:42,500 It's your hobby can do all of these things. 89 00:05:42,740 --> 00:05:49,430 I'm going to go to my split screen to my assistant editor and here I'm going to have to add a few outlets 90 00:05:49,970 --> 00:05:52,240 one outlet which is very simple to understand. 91 00:05:52,280 --> 00:05:53,930 Is this one the scroll wheel. 92 00:05:54,270 --> 00:05:58,200 So that's going to be my Sproull view. 93 00:05:58,490 --> 00:06:01,870 And then I even have my page controller which is again very easy. 94 00:06:01,910 --> 00:06:10,550 My page controller I will have my content to you which is this guide the view that is embedded inside 95 00:06:10,640 --> 00:06:11,940 the school view. 96 00:06:12,020 --> 00:06:19,400 So that's going to be called my content's view and I have one more item that they have to add in here 97 00:06:19,460 --> 00:06:26,330 and that is this constraint the constraint that they made for the vet of my view this one. 98 00:06:26,870 --> 00:06:32,200 So this one I'm going to I'm going to call it that constrains. 99 00:06:32,630 --> 00:06:39,380 So David constraint is essentially going to be blowing me to change the weight of the content based 100 00:06:39,380 --> 00:06:45,620 on the number of the pages to do a quick recap of what we have done in the past and what we should remember 101 00:06:45,620 --> 00:06:52,610 is we need to have a certain number of pages on this page control that if it has five the content size 102 00:06:52,610 --> 00:06:59,150 should be five times the size of the Scroll of view if it is to the content size should be twice as 103 00:06:59,270 --> 00:07:00,990 wide as the scroll view. 104 00:07:01,140 --> 00:07:03,680 So because we don't know what that number is. 105 00:07:03,680 --> 00:07:09,380 And most likely that number will come to us from somebody else such has a network or a backend or so 106 00:07:09,380 --> 00:07:10,360 on and so forth. 107 00:07:10,580 --> 00:07:15,220 We should have a programmatic way of changing that number because of that. 108 00:07:15,230 --> 00:07:19,340 So they have a constraint that they can change it whenever I want to change it. 109 00:07:19,340 --> 00:07:22,060 For now it is sort of 375. 110 00:07:22,130 --> 00:07:26,160 If you want you can actually change you to a random number such as a thousand. 111 00:07:26,360 --> 00:07:32,240 So it becomes a little bit longer than the size of the scroll view and we can test everything now just 112 00:07:32,240 --> 00:07:34,790 to make sure that everything is actually functioning. 113 00:07:35,020 --> 00:07:40,280 Yes go ahead and run the application and if it all works we should be able to see some sort of a scrolling 114 00:07:40,280 --> 00:07:43,150 happening even though there are no content. 115 00:07:43,550 --> 00:07:49,260 So here are my simulator I can go in here now and say this is scroll and I can see the scroll. 116 00:07:49,280 --> 00:07:55,040 And I know that the colors are exactly the same simply because the view what they have in here is white 117 00:07:55,130 --> 00:07:57,170 and the actual view is white as well. 118 00:07:57,380 --> 00:08:03,020 But then I reached the end you can see the light gray background color of view or at the beginning. 119 00:08:03,260 --> 00:08:07,470 So before I leave this story about the last thing I want to do in here is I want to go to my school 120 00:08:07,470 --> 00:08:14,090 of you and say for this school if your paging is a neighborhood because you want to be able to scroll 121 00:08:14,240 --> 00:08:17,430 one page at a time like that one. 122 00:08:17,430 --> 00:08:20,540 And now let's go to our programming site in here. 123 00:08:20,540 --> 00:08:23,900 I'm going to go ahead and say I learned a lot. 124 00:08:24,080 --> 00:08:31,970 They do need is this I need to decide how many pages I have something to say that number of pages to 125 00:08:31,970 --> 00:08:38,750 be let's say 7 for not this is the number that you will get it from somewhere else but for our experiment 126 00:08:38,810 --> 00:08:45,890 I'm just going to make it a static value then I'm going to say once you've laid out depending on the 127 00:08:45,890 --> 00:08:51,920 type of the device you're using I need to know what's the score of you and I need that David because 128 00:08:51,920 --> 00:08:59,450 I need to make my content seven times larger so that what I'm going to call it to be a valuable call 129 00:08:59,450 --> 00:09:04,110 to the vet and that is going to be a CEG float. 130 00:09:04,190 --> 00:09:11,090 But we don't know what that value is just yet where we can get these two values or primarily the value 131 00:09:11,150 --> 00:09:17,300 is within the view will appear that is when the view has been laid out and we can know the size of the 132 00:09:17,300 --> 00:09:18,130 scroll wheel. 133 00:09:18,320 --> 00:09:29,280 So I'm going to go in here and say you will appear and the superb view will appear through in here. 134 00:09:29,440 --> 00:09:38,740 I'm going to say it is actually going to be my you dot bounds dot it. 135 00:09:38,830 --> 00:09:45,680 So we find the of the school view after the view has properly laid out now that they have that value. 136 00:09:45,690 --> 00:09:50,530 I don't know how much should be the overall weight of my content. 137 00:09:50,810 --> 00:09:55,220 That's not the way it's going to be constrained. 138 00:09:55,930 --> 00:10:06,190 I have to get it in your constant and that Konstanz is going to be my favorite multiplied by how many 139 00:10:06,190 --> 00:10:09,490 pages I have a number of pages. 140 00:10:09,610 --> 00:10:16,030 So we get it we want like by the number of pages it is giving me a little error saying that you cannot 141 00:10:16,030 --> 00:10:20,620 multiply something of the type CEG floored by something that is an integer. 142 00:10:20,800 --> 00:10:26,050 And fixing this is very easy because integers can easily become C.G. flawed so I'm going to say give 143 00:10:26,050 --> 00:10:33,160 me the CGU float value of the number of pages and then multiply them together and that becomes the value 144 00:10:33,160 --> 00:10:34,170 of the constant. 145 00:10:34,330 --> 00:10:41,170 So once that is sent or it's constant it's going to become larger numbers seven times bigger than my 146 00:10:41,170 --> 00:10:42,100 school view. 147 00:10:42,220 --> 00:10:47,410 And he's going to push my content views Vitt to become seven times larger. 148 00:10:47,410 --> 00:10:51,680 Now let's go right up to here to make sure everything is working the way we wanted it. 149 00:10:53,480 --> 00:10:59,390 Now in my simulator I can see that I have as much as three. 150 00:10:59,500 --> 00:11:00,320 This is four. 151 00:11:00,320 --> 00:11:03,110 That's actually true but that's how we count it. 152 00:11:03,110 --> 00:11:04,080 This is five. 153 00:11:04,090 --> 00:11:04,890 This is six. 154 00:11:04,910 --> 00:11:06,440 And this is the seventh page. 155 00:11:06,500 --> 00:11:06,830 Great. 156 00:11:06,830 --> 00:11:08,310 Is also working the way we wanted it. 157 00:11:08,310 --> 00:11:12,830 And I think 17 is actually a lot so maybe this down to say four. 158 00:11:13,040 --> 00:11:18,350 So it would be a little bit easier to do all the testing and to view things the way I wanted to view 159 00:11:18,350 --> 00:11:19,310 them. 160 00:11:19,520 --> 00:11:24,310 And then again I'm going to see that I have that one too. 161 00:11:24,380 --> 00:11:25,350 And this is tricky. 162 00:11:25,370 --> 00:11:27,660 Perfect So everything is working the way we want it. 163 00:11:27,680 --> 00:11:32,570 Now it becomes about connecting the page control that the scroll view. 164 00:11:32,570 --> 00:11:38,120 So the first thing we could do which is actually very easy I could say in my view it appears going say 165 00:11:38,150 --> 00:11:48,620 my page control of dot current page set it at 0 and see my page control the number of pages becomes 166 00:11:48,890 --> 00:11:51,580 my valuable number of pages. 167 00:11:51,670 --> 00:11:55,960 Maybe I should have a slightly better now naming because the two of them they seem very similar. 168 00:11:55,960 --> 00:12:00,770 Now with one of them is obviously and actually view of the page one Trauner the other one is my variable 169 00:12:01,130 --> 00:12:06,440 and if I run the application now we should be able to see a page story that has the same number of pages 170 00:12:06,920 --> 00:12:08,610 as does the scroll view. 171 00:12:08,630 --> 00:12:10,060 So now that has four. 172 00:12:10,070 --> 00:12:12,070 And here there are four pages. 173 00:12:12,080 --> 00:12:14,850 Now we want to be able to connect these two together. 174 00:12:15,050 --> 00:12:18,660 And before I do that now some content to my content view. 175 00:12:18,680 --> 00:12:23,200 So when we're scrolling we can actually see some colors or something of the sort. 176 00:12:23,330 --> 00:12:28,570 Now that I'm going to have to use a combination of force view of will appear and view that lot. 177 00:12:28,610 --> 00:12:36,740 So that's sort of I have two views let's call them they're read the view which is a you and I have another 178 00:12:36,740 --> 00:12:42,060 one which is the green view and the green review is going to become a view again. 179 00:12:42,110 --> 00:12:43,520 So I'm going to go in here. 180 00:12:43,580 --> 00:12:51,710 In my view the Lord which I'm going to have to take in my hand and say so as the view that lot I'm going 181 00:12:51,710 --> 00:12:54,650 to have to initialize both red and green. 182 00:12:54,740 --> 00:13:00,680 I'm going to say red because I'm going to say initialize it with a frame and that frame is going to 183 00:13:00,680 --> 00:13:03,000 become cjra like that zero. 184 00:13:03,290 --> 00:13:07,950 So for now they don't have really a space that they take they're just there. 185 00:13:07,970 --> 00:13:15,440 And of course I'm going to have to say my content to you dad I saw you read to you and since this is 186 00:13:15,440 --> 00:13:22,500 called read you maybe we should make the read view that background color become white color got to red. 187 00:13:22,820 --> 00:13:24,010 So this is one of them. 188 00:13:24,050 --> 00:13:25,490 Then I'm going to have the next one. 189 00:13:25,490 --> 00:13:33,700 The next one is the green of you so I will say Green of you again in view adds a frame. 190 00:13:33,710 --> 00:13:35,310 There is no body for it. 191 00:13:35,330 --> 00:13:41,240 And then green becomes green and then my content you the your tweets. 192 00:13:41,350 --> 00:13:48,110 Now the reason I put these two in the view that lot which no actual cjra is simply because they have 193 00:13:48,110 --> 00:13:49,610 to be initialized in here. 194 00:13:49,790 --> 00:13:54,550 But their frame can only be said in here in the view of will appear. 195 00:13:54,560 --> 00:13:58,830 Now you might be wondering so why can't we do all of these things in the view of in appier. 196 00:13:59,000 --> 00:14:04,450 Well if we do all of these things in the view will appear every time the view is about to appear. 197 00:14:04,460 --> 00:14:09,630 All of these things will be done again so you will have multiple copies of your red and green view. 198 00:14:09,800 --> 00:14:14,870 But using a view that this happens only once we get all of these initialized. 199 00:14:15,020 --> 00:14:20,570 But then based on the time that the view is about to appear we sit there size which is a very common 200 00:14:20,570 --> 00:14:22,800 practice and a very good practice. 201 00:14:22,820 --> 00:14:29,790 So in the overlap you may have to set the frame for red if you want to say read you door frame. 202 00:14:29,810 --> 00:14:37,130 Make it a C direct and seizure ex-nun number actually use a different format which is based on origin 203 00:14:37,180 --> 00:14:43,550 and the size so the size of it is actually very easy to see just size of weight and height and those 204 00:14:43,960 --> 00:14:46,390 height are both exactly the same thing. 205 00:14:46,460 --> 00:14:51,840 They are fit because you want them to be exactly the same size of the scroll wheel. 206 00:14:52,100 --> 00:14:56,090 So I copied that and save it and it's the origin of it. 207 00:14:56,090 --> 00:15:00,490 However the C-g point do they have to make out of an x and y values. 208 00:15:00,590 --> 00:15:02,300 One of them is going to be simple. 209 00:15:02,350 --> 00:15:08,780 That's why it has to be zero because we want them to stick to the top corner of the scroll or the content 210 00:15:08,780 --> 00:15:11,290 view which is inside the SQL view. 211 00:15:11,300 --> 00:15:18,730 However the X effect that is for the viridis view is going to be placed between the content of view 212 00:15:19,010 --> 00:15:20,510 and a horizontal level. 213 00:15:20,660 --> 00:15:26,160 I want it to be in the second page so that second page is essentially the index one. 214 00:15:26,330 --> 00:15:35,150 So I will saved it multiplied by 1 so this would essentially push this view as much as one page to the 215 00:15:35,150 --> 00:15:35,790 right. 216 00:15:35,900 --> 00:15:41,300 Let's see that happening before I actually make the green frame as well in the view up here. 217 00:15:41,660 --> 00:15:46,820 So right now in my simulator we should be able to see light after one whole page. 218 00:15:46,820 --> 00:15:50,840 The red one has a start and then everything else is still white. 219 00:15:50,870 --> 00:15:55,530 So let's go ahead and said the same thing for the green one for the green one. 220 00:15:55,700 --> 00:16:01,920 I want to play it not immediately after the read but rather the last page. 221 00:16:01,970 --> 00:16:08,360 So if that is what they want to do I'm going to go ahead and say green view that frame every time without 222 00:16:08,360 --> 00:16:10,080 having to be its size. 223 00:16:10,090 --> 00:16:12,260 It's always going to still be zero. 224 00:16:12,440 --> 00:16:17,470 But the origin x value of it is going to be multiplied by three. 225 00:16:17,660 --> 00:16:23,030 And that's simply because right now at the very beginning of this school view the top left corner is 226 00:16:23,030 --> 00:16:23,920 zero. 227 00:16:23,930 --> 00:16:28,370 If I score as much as 1 this is now 1 the whole of it. 228 00:16:28,370 --> 00:16:34,290 This is not to hold rates have gone to the left side of the screen and this is now true of all of it's 229 00:16:34,290 --> 00:16:35,960 have gone to left of the screen. 230 00:16:36,140 --> 00:16:42,510 Let's see if that actually plays the same way I'm expecting in the simulator of so once the simulator 231 00:16:42,510 --> 00:16:48,160 is up and be a scroll you see the red one and we see the white one and we see the green one. 232 00:16:48,210 --> 00:16:51,380 Now we have to find a way to connect these two together. 233 00:16:51,510 --> 00:16:52,840 Let's go ahead in here. 234 00:16:52,890 --> 00:16:59,370 In my of programming side and I'm going to have to add a new function and that's actually a function 235 00:16:59,370 --> 00:17:00,500 from that delegation. 236 00:17:00,510 --> 00:17:07,690 So I have to go up here and say if you can show that it also conforms to you on a scroll you delegate 237 00:17:08,100 --> 00:17:14,220 and the method that I want to get access to is a scroll if you did the escrowed. 238 00:17:14,430 --> 00:17:19,740 So every time that the scroll I want to know about the scrolling and I want to know where I am in the 239 00:17:19,740 --> 00:17:20,640 scroll. 240 00:17:20,640 --> 00:17:26,010 Now the very you all in the scroll is actually has a certain value for it right now. 241 00:17:26,020 --> 00:17:28,810 This girl is at the very beginning is zero. 242 00:17:28,860 --> 00:17:31,820 That is what we call it the content of set. 243 00:17:31,860 --> 00:17:39,160 Imagine this large view that is under the scroll of view being white red white and green. 244 00:17:39,300 --> 00:17:41,900 That's a very wide view that is there. 245 00:17:41,910 --> 00:17:47,560 And if you would imagine it is spilling outside the simulator you could view something like this. 246 00:17:47,580 --> 00:17:53,010 It would be a view that is like this is much larger but you're seeing only a portion of it. 247 00:17:53,040 --> 00:18:00,890 Now that view we are currently at a certain offset in a certain place right now the offset is zero. 248 00:18:00,960 --> 00:18:03,250 Right now the offset is one hole. 249 00:18:03,420 --> 00:18:08,550 And that's exactly the number that we need someone to go in here and say let's I'm going to call this 250 00:18:08,550 --> 00:18:16,090 one x origin let's call it my scroll of view or the scroll of view because they are both referring to 251 00:18:16,090 --> 00:18:25,080 the same value scroll view that the content of set dot X so find the content of set for me then I'm 252 00:18:25,080 --> 00:18:27,140 going to go ahead and say let. 253 00:18:27,150 --> 00:18:28,550 Next page. 254 00:18:28,690 --> 00:18:31,900 Just the page that you want to show on the page control. 255 00:18:32,100 --> 00:18:41,670 That's going to be the value of dividing this by the value of the V. 256 00:18:41,950 --> 00:18:47,710 So for instance if the X origin is twice as much as the weight that number becomes two if the value 257 00:18:47,710 --> 00:18:52,270 of this division is thrice as big that value becomes three. 258 00:18:52,390 --> 00:18:53,890 So on and so forth. 259 00:18:53,890 --> 00:18:55,300 Now there is a little problem. 260 00:18:55,300 --> 00:19:00,530 These two are both C.G. floats and obviously this value is becoming a C.G. float. 261 00:19:00,640 --> 00:19:05,760 Well I knew that to be an integer and if I tried to force it is going to give me an error saying Well 262 00:19:05,780 --> 00:19:07,920 both of these guys are C.G. frauds. 263 00:19:08,020 --> 00:19:13,030 So I'm going to say actually give me the integer value of these two. 264 00:19:13,030 --> 00:19:16,770 Now I want explain something else for you guys which I know is going to come up obviously. 265 00:19:16,810 --> 00:19:19,320 I've done this before and I know it happening. 266 00:19:19,320 --> 00:19:23,320 And even if you don't you can just try it once and you will see the problem. 267 00:19:23,350 --> 00:19:30,960 The problem is this If the division of X or Asian by it is for instance two point eight It still is 268 00:19:30,970 --> 00:19:38,440 going to become true because an integer value while at 2.8 we are half way past and we would like to 269 00:19:38,440 --> 00:19:40,660 be able to go to the next page. 270 00:19:40,660 --> 00:19:48,030 So essentially any number within the decimal values which is above 0.5 should become the next one and 271 00:19:48,030 --> 00:19:53,410 a number in order pointwise 5 should become the previous one to fix that. 272 00:19:53,410 --> 00:19:56,800 I'm going to say let's get the round of these numbers. 273 00:19:56,920 --> 00:20:03,280 So let's round it to be whatever number you find between these two. 274 00:20:03,280 --> 00:20:09,690 So basically when you're around it anything that is like 2.5 1 it becomes three things. 275 00:20:09,710 --> 00:20:12,890 But it's like two point four nine it becomes two. 276 00:20:13,000 --> 00:20:18,550 So this splits point the breaking point becomes at point five which is exactly what we need. 277 00:20:18,550 --> 00:20:24,480 And finally I'm going to say my page controller that current page becomes the next stage. 278 00:20:24,490 --> 00:20:29,530 Now before I run the code there is a tiny teeny bit of code that I have totally forgot and I'm hoping 279 00:20:29,530 --> 00:20:30,940 that you guys remember it. 280 00:20:31,150 --> 00:20:36,830 And that is even though we are using a delegate method we are using a score you delegate. 281 00:20:36,850 --> 00:20:38,760 I never delegate at my school. 282 00:20:38,830 --> 00:20:40,500 So let's go ahead and do that. 283 00:20:40,550 --> 00:20:47,500 Our That lot so down in here in my view that lot I'm going to go ahead and say my school view that delegate 284 00:20:47,560 --> 00:20:52,840 becomes self you could either do this in the code or do it in the Interface Builder. 285 00:20:52,860 --> 00:20:56,690 Most of them would essentially mean the same thing I would do exactly the same thing. 286 00:20:56,890 --> 00:21:04,180 But I'm glad to hear in the court now once my simulator boots up I should be able to scroll and then 287 00:21:04,220 --> 00:21:11,510 half the zoom up to the left that was a very bad idea. 288 00:21:11,720 --> 00:21:13,990 Halfway through each to the other side. 289 00:21:14,150 --> 00:21:15,120 Exactly. 290 00:21:15,290 --> 00:21:16,910 Let's go ahead and show it again. 291 00:21:17,170 --> 00:21:22,760 Purrfect that next one and then next one. 292 00:21:22,830 --> 00:21:27,680 Right at the half a breaking point it decides which way it has to go to. 293 00:21:27,830 --> 00:21:30,940 Now that's all good and well and working the way we want it to work. 294 00:21:30,950 --> 00:21:36,740 But there's still one piece missing and that is what if I type on the page controller shouldn't we go 295 00:21:36,820 --> 00:21:39,530 and I made this scroll of you what will happen. 296 00:21:39,530 --> 00:21:43,770 So to do that we need to have a function connected to our page controllers. 297 00:21:43,820 --> 00:21:46,930 We can't do that either by code or using the storyboard. 298 00:21:47,000 --> 00:21:52,010 I usually do it in the story but I actually want to do it in the coding interface because I want to 299 00:21:52,010 --> 00:21:53,930 see that happening in here as well. 300 00:21:54,140 --> 00:22:02,720 So I want to go ahead and say my page controller in the view that lot is going to have a target and 301 00:22:02,720 --> 00:22:09,920 that target is within your self and the action for it is at select all. 302 00:22:09,950 --> 00:22:16,240 And we have to find an action for it and the control event for it is value changed. 303 00:22:16,280 --> 00:22:22,730 So we have to get that then I'm going to add a new function then your function is called the function 304 00:22:23,390 --> 00:22:24,860 page function. 305 00:22:25,220 --> 00:22:28,430 And there's an argument for it that I'm going to call it send there. 306 00:22:28,550 --> 00:22:34,770 And that said there is a page control and I don't have any return for it is void. 307 00:22:34,820 --> 00:22:39,610 So we're going to call paged and since for using this page as a selector. 308 00:22:39,610 --> 00:22:44,040 I have to export it as an objective c so objective c page. 309 00:22:44,090 --> 00:22:46,800 And then this selector is going to be calling that. 310 00:22:46,930 --> 00:22:48,390 And then the body of the function. 311 00:22:48,390 --> 00:22:49,500 Here's what they want to do. 312 00:22:49,700 --> 00:22:57,200 I want to know which page we are on the controller here or view at zero like one break right now two 313 00:22:57,200 --> 00:22:57,930 or three. 314 00:22:58,040 --> 00:23:02,210 And then depending on that I want to scroll the school view to slumber. 315 00:23:02,270 --> 00:23:09,000 So for that I'm going to go ahead and say let's let's call it index. 316 00:23:09,300 --> 00:23:16,290 It's going to become center there which is the page where they're sending us that Clarence Page. 317 00:23:16,470 --> 00:23:20,490 So we know which page we are out on let's call it next page. 318 00:23:20,490 --> 00:23:22,260 Actually a better name for it. 319 00:23:22,260 --> 00:23:25,530 So next page is send that current page. 320 00:23:25,740 --> 00:23:30,880 Then we have to produce a new frame where we want a score of you to go to. 321 00:23:31,050 --> 00:23:38,610 So I'm going to go ahead and say let me frame the new frame I'm going to be it's called a CGI record 322 00:23:38,990 --> 00:23:41,930 on my CGI recked is made just like the last time. 323 00:23:41,940 --> 00:23:46,500 But the point on a size the size of it is that easier once I'm going to write it first. 324 00:23:46,500 --> 00:23:49,120 The size is going to be the same size. 325 00:23:49,140 --> 00:23:55,380 It has been for a while and that is the way to unhide both of them are equivalent to our vet because 326 00:23:55,380 --> 00:23:58,860 we are not changing the size of the frame of our skull. 327 00:23:59,130 --> 00:24:05,840 What we are changing is where does it points to a single point and the point is going to become the 328 00:24:06,690 --> 00:24:09,080 x and y values of it are important. 329 00:24:09,080 --> 00:24:15,370 The wife is obviously 0 the X of it becomes which page you are trying to show. 330 00:24:15,900 --> 00:24:19,660 And we have to multiply that by that. 331 00:24:19,950 --> 00:24:20,860 Let me explain this. 332 00:24:20,880 --> 00:24:21,750 There's going to be an error. 333 00:24:21,750 --> 00:24:22,600 Don't worry about that. 334 00:24:22,620 --> 00:24:25,070 Will fix that in a second but let me explain this. 335 00:24:25,260 --> 00:24:32,840 So what's happening is I'm saying if the next page that you have to show is 0 0 multiplied by whatever 336 00:24:32,860 --> 00:24:40,350 fish going be sure the very top left corner of the scroll or if the next page is 1 vs scroll as much 337 00:24:40,350 --> 00:24:41,650 as one. 338 00:24:41,880 --> 00:24:47,950 If the next page is three if you scroll as much as trivets And that's exactly what we need it to do. 339 00:24:48,150 --> 00:24:53,880 So the only thing that is missing in here is that it's seeing the next page is actually a an integer 340 00:24:53,880 --> 00:25:00,480 value what you need the float value someone is saying give me a C.G. float value of the next page and 341 00:25:00,490 --> 00:25:02,310 multiply by derivate. 342 00:25:02,310 --> 00:25:06,800 So now we have the new frame that we know that the school you should go there. 343 00:25:06,960 --> 00:25:08,510 Tovey should also go there. 344 00:25:08,580 --> 00:25:18,770 So I'm going to say my scroll view dot is cruel next to a visible scroll it is this new frame. 345 00:25:18,960 --> 00:25:20,330 And is it animated. 346 00:25:20,370 --> 00:25:21,980 Yes. 347 00:25:22,050 --> 00:25:29,880 So you're scrolling the scroll view not manually by the user animating or or tapping right there by 348 00:25:29,880 --> 00:25:33,620 a problematic review or scrolling you to a certain place. 349 00:25:33,630 --> 00:25:38,080 Let's see if that's going to work the way I'm suggesting with more. 350 00:25:38,210 --> 00:25:43,790 So now that they have the simulator on I can do this just like before I can type in there and it will 351 00:25:43,870 --> 00:25:46,790 automatically scroll the scroll wheel. 352 00:25:47,450 --> 00:25:51,450 So every time I type it will go and find the current page in here. 353 00:25:51,470 --> 00:25:55,690 And based on that it will push the view to that particular offering. 354 00:25:56,000 --> 00:25:57,440 And that's all we have to do. 355 00:25:59,340 --> 00:26:05,930 Now you might notice a little error in here and that is when I type it tries to go to the next stage 356 00:26:06,380 --> 00:26:13,580 then switches back and then goes and that's simply because when I tap on the page or by default it wants 357 00:26:13,580 --> 00:26:14,880 to jump to the next one. 358 00:26:15,070 --> 00:26:20,480 And it does that for a split site and pay attention to this really quickly it goes there. 359 00:26:20,480 --> 00:26:27,020 But then it comes back and that's simply because as it goes to the next page it says that the way a 360 00:26:27,020 --> 00:26:33,640 scroll of you did scroll is actually trying to force it to be in a different place because when we tap 361 00:26:33,640 --> 00:26:38,980 in here and the animation of the school view begins this thing is also happening. 362 00:26:38,990 --> 00:26:44,930 A school of view is a scrolling and based on somebody saying oh no you shouldn't be there just yet. 363 00:26:44,930 --> 00:26:46,690 You haven't reached halfway. 364 00:26:46,820 --> 00:26:50,570 So they're both essentially working against each other to fix that. 365 00:26:50,570 --> 00:26:56,900 I have a suggestion and my suggestion is that we find a way to know that if we are currently using the 366 00:26:56,900 --> 00:27:01,660 paging we are animating manually this thing shouldn't happen. 367 00:27:01,670 --> 00:27:09,230 So once again if you're animating using this school view animation we shouldn't be accounting for this 368 00:27:09,230 --> 00:27:09,860 thing. 369 00:27:10,010 --> 00:27:12,530 So let's go ahead and write that in code. 370 00:27:12,530 --> 00:27:20,300 I'm going to go up in here on the new value about the value of man animating which is by default false 371 00:27:20,330 --> 00:27:25,230 because we are not animating by default by default scrolling manually. 372 00:27:25,490 --> 00:27:31,630 So I'm going to go in here and say this entire thing should only happen if we are not animating. 373 00:27:31,640 --> 00:27:38,840 So if not animating which is the default mode all of these things should happen. 374 00:27:38,840 --> 00:27:42,950 Which is exactly what we have been doing up until this point. 375 00:27:43,040 --> 00:27:46,170 All of these are happening because we were not animating. 376 00:27:46,370 --> 00:27:47,490 Let's run this now. 377 00:27:49,240 --> 00:27:51,790 And now everything is working the way we wanted it. 378 00:27:51,800 --> 00:27:57,740 We still have the same problem that the dots on the page controller they turn on momentarily and then 379 00:27:57,740 --> 00:27:59,790 they turn off from time to time. 380 00:27:59,870 --> 00:28:01,230 So we have to address that. 381 00:28:01,270 --> 00:28:07,420 So I'm going to come in and say everything that views the page everything that we do that go ahead and 382 00:28:07,420 --> 00:28:10,440 make the animating become truth. 383 00:28:10,460 --> 00:28:14,000 So we are constantly animating using this guy. 384 00:28:14,240 --> 00:28:15,890 So let's see how that works. 385 00:28:17,920 --> 00:28:22,670 So now when I start they go perfectly from one to another to another to another. 386 00:28:22,800 --> 00:28:26,290 And none of those things that we were experiencing before happened. 387 00:28:26,830 --> 00:28:33,040 But you can imagine that now we have a different problem and that different problem is the animating 388 00:28:33,040 --> 00:28:34,540 is set to true. 389 00:28:34,570 --> 00:28:41,260 And if I do this it won't have any impact on the page control anymore simply because anything is not 390 00:28:41,350 --> 00:28:42,490 always true. 391 00:28:42,580 --> 00:28:47,300 So we have to find a way to make the animating actually false from time to time. 392 00:28:47,440 --> 00:28:50,050 And then we have to set the animating to false. 393 00:28:50,070 --> 00:28:56,320 Again that is Vendy is clearly always Isabel has finished and there is an actual delegate method for 394 00:28:56,320 --> 00:28:56,580 that. 395 00:28:56,580 --> 00:29:01,240 And that's the one I showed you a few lessons ago and I told you I even tried to embedded in one of 396 00:29:01,240 --> 00:29:05,880 the future lessons Previously I used to solve this problem in a different way. 397 00:29:06,010 --> 00:29:08,680 But now I thought that I could show you that method as well. 398 00:29:08,740 --> 00:29:11,580 So it's got to a school of your delegates. 399 00:29:12,010 --> 00:29:15,090 If it does show me some it plays a trick on me. 400 00:29:15,100 --> 00:29:22,710 So jump to the definition and there is something called escrowed view of end and scrolling animation. 401 00:29:22,720 --> 00:29:24,440 So that's the one that they need. 402 00:29:24,690 --> 00:29:28,600 It's going you say right after this one 403 00:29:31,390 --> 00:29:33,040 and animating. 404 00:29:33,390 --> 00:29:37,360 So a school of you did an animation so I know animate thing. 405 00:29:37,600 --> 00:29:40,500 So everything does and animation. 406 00:29:40,570 --> 00:29:46,620 I want to say animating because once again because it's not animating anymore. 407 00:29:46,870 --> 00:29:50,230 So let's go ahead and run this again. 408 00:29:50,270 --> 00:29:56,510 So now I have my simulator up I can scroll on I see them they happening and I can tap on those and they 409 00:29:56,510 --> 00:29:58,990 perfectly work the way I expected them. 410 00:29:59,000 --> 00:30:04,220 You don't have that little glitch happening anymore because the value of the animating gets to be true 411 00:30:04,220 --> 00:30:11,330 every time that we are animating using the PH controller and every time that we scroll we see them jumping 412 00:30:11,330 --> 00:30:17,030 from one point to the other one depending on the location of the offset which is exactly what we were 413 00:30:17,030 --> 00:30:18,070 hoping to see. 414 00:30:18,350 --> 00:30:19,670 So that's about it. 415 00:30:19,670 --> 00:30:22,760 A very long exercise I must say. 416 00:30:22,760 --> 00:30:30,170 We covered a lot of cons from doing the kind of strains from using a cross-train as an outlet to changing 417 00:30:30,170 --> 00:30:37,310 the values of the different you know views and placing them in different spots in the SQL view to finally 418 00:30:37,310 --> 00:30:44,090 getting this core view content of set value within the school view the school and then eventually adding 419 00:30:44,090 --> 00:30:47,890 a page function to our page control. 420 00:30:48,110 --> 00:30:52,200 So let's keep it up to here and move on to our next lesson.