-
Notifications
You must be signed in to change notification settings - Fork 149
/
7. Multiple MVCs, Timer, and Animation.srt
6016 lines (4521 loc) · 128 KB
/
7. Multiple MVCs, Timer, and Animation.srt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1
00:00:00,401 --> 00:00:04,736
本字幕由志愿者义务贡献,采用许可协议
知识共享 署名-非商业性使用-相同方式共享 3.0 美国
2
00:00:04,805 --> 00:00:09,374
>> Stanford University. >> Hey, well,
>> 斯坦福大学 >> 大家好
3
00:00:09,443 --> 00:00:14,012
welcome to Lecture number 7, Stanford CS193P, Fall 2017. So
欢迎来到 2017 年秋季学期 CS193P 的第七节课
4
00:00:14,080 --> 00:00:19,351
our primary topic today is combining MVCs to make bigger,
今天,我们的主要任务显然就是将多个 MVC 组合成组件更多,
5
00:00:19,420 --> 00:00:22,153
more powerful applications, obviously. And
功能更强大的应用程序。
6
00:00:22,222 --> 00:00:24,890
then I'm gonna do a big demo that shows you how to do that.
同时,我也将示范编写一个更大的样例程序来向你们展示该如何完成这项工作。
7
00:00:24,959 --> 00:00:27,559
We're gonna do it with Concentration, we're gonna add
本次的示范将以 Concentration 这个 app 为基础,我们将来要向其添加
8
00:00:27,627 --> 00:00:30,929
an MVC into that app. Then I'll come back to the slides,
一个 MVC。然后我会回到幻灯片上,
9
00:00:30,998 --> 00:00:33,865
and talk I'll about timer and choose classes, some of you
(这里疑似all about)我会讲授有关计时器和选择类的相关内容,
10
00:00:33,934 --> 00:00:37,169
used in the extra credit of the homework assignments. And
这部分内容你们可能会在作业的选做部分需要用到。
11
00:00:37,237 --> 00:00:39,004
then I'm gonna dive into the next topic and try and
然后的时间我会尽可能深入讲解下一个主题,也就是动画部分,
12
00:00:39,073 --> 00:00:41,373
get as far as I can which is animation.
能讲多少讲多少。
13
00:00:41,442 --> 00:00:43,275
Which will be our topic on Wednesday and
这也将是我们在周三的课程上的主要内容,
14
00:00:43,343 --> 00:00:45,376
I'll get to much more detail, do a big demo.
并且我会更深入地讲解更多细节性内容,做一个更大的示范程序。
15
00:00:45,445 --> 00:00:47,512
But I wanna kinda get in as far as I can today just so
我今天会尽可能地讲解理论部分的内容,
16
00:00:47,581 --> 00:00:50,916
we have more time for a demo on Wednesday.
这样我们周三上课时就会有足够的时间进行操作示范。
17
00:00:50,984 --> 00:00:54,486
Alright so combining MVCs, remember this slide from when
回到整合 MVC 上来,还记得我们讲解 MVC 时使用的这张幻灯片吗?
18
00:00:54,555 --> 00:00:58,190
I talked about MVC. This is the MVCs working together, and
这就是多个 MVCs 协同工作的示意图,
19
00:00:58,259 --> 00:01:01,193
we saw that when we have MVCs working together,
我们可以看到,当多个 MVCs 协同工作时,
20
00:01:01,261 --> 00:01:04,862
these other MVCs. Let me get my thing under control here,
其他的 MVC……(此处幻灯片动画出错)让我把它修好……
21
00:01:04,931 --> 00:01:08,967
well, can't do it. Okay, these other MVCs down in the corner,
好吧,它彻底坏掉了。其他的角落里的 MVCs
22
00:01:09,036 --> 00:01:12,170
they serve as part of the view of another MVC. That's
他们通过控制其他 MVC 中的一个 view,来为整个 app 服务。
23
00:01:12,239 --> 00:01:16,608
the way MVC's relate. An MVC is a view, part of a view
这就是 MVC 之间相互联系的方法。一个 MVC 就是一个 view,同时也是其他类中的 view 的一部分。
24
00:01:16,677 --> 00:01:19,811
of another class. And that has some ramifications for MVC,
25
00:01:19,880 --> 00:01:22,781
most notably it has to have blind structured communication
26
00:01:22,849 --> 00:01:26,618
back to the other MVC. But that's the way we
27
00:01:26,687 --> 00:01:29,154
structure it, and that keeps everything well contained and
28
00:01:29,222 --> 00:01:32,523
understandable. So we're gonna talk about how we do that,
29
00:01:32,592 --> 00:01:36,595
how we make MVCs that are the view of other MVCs. So,
30
00:01:36,663 --> 00:01:40,065
combining MVCs we do this using some special
31
00:01:40,133 --> 00:01:44,569
controllers that iOS provides whose view is other MVCs.
32
00:01:44,638 --> 00:01:48,339
Now you could write your own special MVC whose view is
33
00:01:48,408 --> 00:01:52,544
other MVCs. But 99% of the time you're gonna use one of
34
00:01:52,612 --> 00:01:55,980
the three that iOS provides. And the three that iOS
35
00:01:56,049 --> 00:01:59,418
provides are TabBarController, SplitViewController, and
36
00:01:59,486 --> 00:02:02,520
navigation controller. Now there are other ways to
37
00:02:02,589 --> 00:02:05,157
combine MVCs we'll talk about later in the quarter but
38
00:02:05,225 --> 00:02:07,859
this is the primary way that we're gonna do it with these
39
00:02:07,928 --> 00:02:11,229
three MVC's. Those three here, TabBar, SplitView, and
40
00:02:11,298 --> 00:02:15,567
NavigationController, they are the controllers of MVCs. So
41
00:02:15,636 --> 00:02:17,002
let's look at them one by one.
42
00:02:17,070 --> 00:02:18,870
TabBar is by far the simplest one,
43
00:02:18,939 --> 00:02:22,240
you've seen this a million times, it's got
44
00:02:22,309 --> 00:02:24,475
some tabs along the bottom there. You see those tabs,
45
00:02:24,544 --> 00:02:27,179
like a little orange thing and the gray one's next to it. And
46
00:02:27,247 --> 00:02:31,049
each of those tabs, when you press it, shows another MVC.
47
00:02:31,117 --> 00:02:34,519
So you can already see that the TabBarController's view
48
00:02:34,588 --> 00:02:39,257
includes the buttons at the bottom and another MVC. So
49
00:02:39,326 --> 00:02:42,227
this is what we mean by the view of this tab bar
50
00:02:42,295 --> 00:02:46,498
controller MVC gives another MVC. And the icon and
51
00:02:46,567 --> 00:02:48,566
the title that appears down in the TabBar,
52
00:02:48,635 --> 00:02:51,570
that's determined by which MVC is showing.
53
00:02:51,638 --> 00:02:55,240
In specific UI view controller has this bar TabBar item.
54
00:02:55,308 --> 00:02:58,709
And the TabBar controller, when it shows the MVC as part
55
00:02:58,778 --> 00:03:02,280
of its view, it looks at that so it knows what the title and
56
00:03:02,349 --> 00:03:05,917
icon to display down at the bottom there. This is all very
57
00:03:05,986 --> 00:03:10,722
object oriented in that sense. So, for example here we've got
58
00:03:10,791 --> 00:03:13,658
some sort of health oriented API here and
59
00:03:13,727 --> 00:03:16,961
we've got the four tabs at the bottom. By the way, if there's
60
00:03:17,030 --> 00:03:21,300
more than four tabs, more than four MVCs, it can show that,
61
00:03:21,368 --> 00:03:24,469
actually, it'll show five. And if they're six, then
62
00:03:24,538 --> 00:03:27,439
the fifth one becomes a little more button and you click it.
63
00:03:27,508 --> 00:03:31,243
And iOS provides an API or UI, rather, for the user to pick
64
00:03:31,311 --> 00:03:33,044
which tabs they want to be there at the bottom, or
65
00:03:33,113 --> 00:03:35,480
to pick some other tab that's not showing. Generally though,
66
00:03:35,549 --> 00:03:39,384
we recommend no more than five MVCs in a TabBarController.
67
00:03:39,452 --> 00:03:41,720
That's kinda just pretty good UI,
68
00:03:41,789 --> 00:03:43,154
It just starts to get a little complicated for
69
00:03:43,223 --> 00:03:46,291
the user if there's more than that. So, in this case,
70
00:03:46,360 --> 00:03:50,395
this whole thing is five MVCs, the TabBarController itself,
71
00:03:50,463 --> 00:03:53,131
and the four MVCs that serve as its view and
72
00:03:53,200 --> 00:03:55,934
you just switch between them by clicking.
73
00:03:56,002 --> 00:04:00,805
So this is by far the easiest Of the MVCs of MVCs,
74
00:04:00,874 --> 00:04:04,008
all right? Next, let's talk about SplitViewController,
75
00:04:04,077 --> 00:04:06,911
probably the second simplest one. It's only two MVCs in its
76
00:04:06,980 --> 00:04:10,348
view, and it puts them side by side with a very thin line in
77
00:04:10,417 --> 00:04:13,751
between them. So, here's a little calculator app,
78
00:04:13,820 --> 00:04:16,454
It's got the calculator on the left and then it's got maybe
79
00:04:16,523 --> 00:04:19,790
a graph of what's in the calculator on the right. And
80
00:04:19,859 --> 00:04:23,628
we call this MVC that's on the left, and it's usually smaller
81
00:04:23,697 --> 00:04:27,132
like this, the Master in the SplitViewController, and
82
00:04:27,200 --> 00:04:30,134
we call the one on the right the Detail. And
83
00:04:30,203 --> 00:04:32,471
we call them master detail cuz usually what you do on the one
84
00:04:32,539 --> 00:04:34,672
on the left affects what happens on the right. It's
85
00:04:34,741 --> 00:04:37,942
the master, the detail is kind of little bit of a slave. And,
86
00:04:38,011 --> 00:04:42,614
of course, this is on iPad. It also works on iPhone Pluses,
87
00:04:42,682 --> 00:04:47,084
but non-plus iPhones. This little side-by-side mechanism.
88
00:04:47,153 --> 00:04:48,486
You can, of course, rotate your iPad.
89
00:04:48,555 --> 00:04:51,089
And when you rotate your iPad into portrait, now
90
00:04:51,157 --> 00:04:55,026
it'll only show the detail, except for you can slide out
91
00:04:55,094 --> 00:04:57,528
with your finger from the left and see the Master,
92
00:04:57,597 --> 00:05:01,899
then slide it back. Now on an iPhone Plus in portrait,
93
00:05:01,968 --> 00:05:04,403
it acts like a normal iPhone, it doesn't have the slide out.
94
00:05:04,471 --> 00:05:06,904
Even if an iPhone Plus is not quite wide enough to
95
00:05:06,973 --> 00:05:11,810
slide that thing out. So, SplitViewController, super,
96
00:05:11,878 --> 00:05:14,646
super easy. And then there's NavigationController.
97
00:05:14,715 --> 00:05:17,282
This is probably the most flexible, most powerful of
98
00:05:17,350 --> 00:05:20,652
the MVC of MVCs, you've seen this a million times in IOS
99
00:05:20,720 --> 00:05:23,855
apps. You can think of a NavigationController MVC,
100
00:05:23,924 --> 00:05:28,025
as a deck of cards. And each card is an MVC. And what
101
00:05:28,094 --> 00:05:31,829
the navigation controller does is let you put an MVC on top,
102
00:05:31,898 --> 00:05:34,499
obscuring all the ones below. And then if you hit the back
103
00:05:34,568 --> 00:05:37,201
button, it throws that one away, and shows you the one
104
00:05:37,270 --> 00:05:39,337
that was there before. And you can keep going back, and
105
00:05:39,406 --> 00:05:40,871
it keeps showing the cards off the top, and
106
00:05:40,940 --> 00:05:44,009
you put new cards back on. So it's like a card stack, where
107
00:05:44,077 --> 00:05:48,512
the stack are MVCs. And you can see that the navigation
108
00:05:48,581 --> 00:05:51,583
controller as part of its view it does actually draw a little
109
00:05:51,652 --> 00:05:54,319
bit. At the top it draws a little title there, right?
110
00:05:54,388 --> 00:05:57,155
The settings, okay, that's not part of the MVC that's
111
00:05:57,224 --> 00:06:00,458
showing right there. But the content that are in that title
112
00:06:00,527 --> 00:06:03,562
are driven by whatever MVCs on top of the card stack,
113
00:06:03,630 --> 00:06:06,965
the one that's showing. So that's called settings
114
00:06:07,034 --> 00:06:09,734
because the MVC that's there is the settings MVC, so
115
00:06:09,803 --> 00:06:13,605
it's being driven by what's there. And each MVC,
116
00:06:13,674 --> 00:06:16,708
similar with the tab bar item and the tab bar controller,
117
00:06:16,776 --> 00:06:21,012
there's a var in UI Controller called navigationItem. And
118
00:06:21,081 --> 00:06:24,649
that contains things like the title and other buttons that
119
00:06:24,717 --> 00:06:27,252
you can put in the title bar, all kinds of stuff.
120
00:06:27,320 --> 00:06:28,953
You're gonna wanna go look at the documentation for
121
00:06:29,022 --> 00:06:29,754
navigationItem and
122
00:06:29,823 --> 00:06:32,657
see what kind of things the navigation controller can
123
00:06:32,725 --> 00:06:37,596
do for you when your MVC is on top of the stack. So
124
00:06:37,664 --> 00:06:40,732
if I then click on something, this is a table view here,
125
00:06:40,800 --> 00:06:44,001
we'll talk about table views next week or the week after.
126
00:06:44,070 --> 00:06:47,639
If I click on something here then a new MVC slides in,
127
00:06:47,708 --> 00:06:52,477
animates in on top. Now there are two cards on this stack.
128
00:06:52,546 --> 00:06:54,179
All settings one which is now behind,
129
00:06:54,247 --> 00:06:57,715
we can't see it, and now this new one on top of course.
130
00:06:57,784 --> 00:06:59,618
By the way you can also have tool bar
131
00:06:59,686 --> 00:07:02,353
items on the bottom using the tool bar items bar of view
132
00:07:02,422 --> 00:07:04,288
controller, so those two of our items would come and
133
00:07:04,357 --> 00:07:07,626
go as new ones come on the stack. But
134
00:07:07,694 --> 00:07:09,961
also notice that when we have two things on there,
135
00:07:10,030 --> 00:07:11,863
a little back button appears in the upper left,
136
00:07:11,932 --> 00:07:15,600
automatically. It even has the name of the one that's
137
00:07:15,668 --> 00:07:18,903
lower down on the stack of cards. And if you press that,
138
00:07:18,972 --> 00:07:20,805
of course it's gonna throw this card away, and
139
00:07:20,873 --> 00:07:23,842
we'll be back at the other card. But lets imagine I click
140
00:07:23,910 --> 00:07:25,409
on something in this one like this
141
00:07:25,478 --> 00:07:27,679
accessibility thing. It puts a new card on there,
142
00:07:27,747 --> 00:07:30,781
that's the accessibility card. Maybe I click on something
143
00:07:30,850 --> 00:07:33,718
inside the accessibility card like larger text, and it puts
144
00:07:33,786 --> 00:07:37,388
another one on. Now we have four MVCs on the the stack.
145
00:07:37,457 --> 00:07:39,156
So there's a total of five MVCs here.
146
00:07:39,225 --> 00:07:41,926
The navigation controller itself which is an MVC, and
147
00:07:41,995 --> 00:07:46,197
these four MVCs which are part of its view. And of course we
148
00:07:46,266 --> 00:07:48,333
know we can backup if we pres the back button and
149
00:07:48,401 --> 00:07:50,902
it throws that button away, and it actually does throws
150
00:07:50,971 --> 00:07:53,237
the card away. Throws it out of the heap.
151
00:07:53,306 --> 00:07:55,773
So it's complete throw away, this card now gets thrown
152
00:07:55,842 --> 00:07:58,242
away, we are just now seeing the card on the underneath
153
00:07:58,311 --> 00:08:01,212
until we go all the way the back, To the beginning and
154
00:08:01,281 --> 00:08:03,180
now we're seeing the root card, the root
155
00:08:03,249 --> 00:08:06,150
view controller, this is called a navigationController.
156
00:08:06,219 --> 00:08:08,385
All right, so everybody knows about navigationController,
157
00:08:08,454 --> 00:08:09,787
you've seen it everywhere.
158
00:08:09,856 --> 00:08:12,089
Here's how navigational controller's working behind
159
00:08:12,158 --> 00:08:15,527
the scenes in terms of looking at it from an MVC standpoint.
160
00:08:15,596 --> 00:08:18,462
So let's say I have a MVC that's shown there,
161
00:08:18,531 --> 00:08:21,198
and I have more API or more UI than I can fit on
162
00:08:21,267 --> 00:08:25,369
my screen, so I need to got to another screen to do more UI.
163
00:08:25,438 --> 00:08:27,905
That's the little thing in the corner right there. Well, to
164
00:08:27,974 --> 00:08:31,142
do that I have to make another MVC that will control that UI.
165
00:08:31,210 --> 00:08:34,078
And then when I make my navigationController
166
00:08:34,147 --> 00:08:37,015
to have them share the screen, the navigationController comes
167
00:08:37,083 --> 00:08:39,684
up and this is what its UI looks like. But as soon
168
00:08:39,752 --> 00:08:42,587
as you set a very important var in navigationController,
169
00:08:42,656 --> 00:08:45,690
call it rootViewController to be some MVC,
170
00:08:45,759 --> 00:08:51,162
then its view now includes the view of that MVC. And
171
00:08:51,231 --> 00:08:54,298
then, if you interact with some button or
172
00:08:54,367 --> 00:08:56,534
something that's in that MVC's view,
173
00:08:56,603 --> 00:09:00,472
it can move to this other MVC, push it on the stack.
174
00:09:00,540 --> 00:09:02,173
Now the other MVC is still there, it's just kind of
175
00:09:02,242 --> 00:09:05,644
behind the scenes because it's lower on the stack, and a back
176
00:09:05,712 --> 00:09:07,378
button will automatically appear as we saw.
177
00:09:07,447 --> 00:09:10,882
When we click this back we move back to the other one,
178
00:09:10,951 --> 00:09:14,285
and notice that the MVC that we had originally added
179
00:09:14,354 --> 00:09:17,522
on there is gone. So it's very important to understand
180
00:09:17,591 --> 00:09:19,056
as we use the navigationController,
181
00:09:19,125 --> 00:09:21,392
usually when we put things on we're creating a new one and
182
00:09:21,461 --> 00:09:23,461
when we take things off we're throwing it away.
183
00:09:23,530 --> 00:09:27,164
That is the normal operation of a navigationController. It
184
00:09:27,233 --> 00:09:30,669
can be used in other ways but that is it's normal operation.
185
00:09:31,971 --> 00:09:36,341
Okay, so those are the three kinds of MVCs of MVCs.
186
00:09:36,409 --> 00:09:40,444
How do you get at them? Okay, it's really easy actually.
187
00:09:40,513 --> 00:09:44,015
Each of those three different kinds of MVCs has a var called
188
00:09:44,084 --> 00:09:46,951
viewControllers, it's just an array of view controller. So
189
00:09:47,020 --> 00:09:49,854
for a tab bar it's just the view controllers one, two,
190
00:09:49,923 --> 00:09:52,089
three, four in order I think from left to right,
191
00:09:52,158 --> 00:09:54,426
the tabs. If it's a split-view controller,
192
00:09:54,494 --> 00:09:57,128
then view controller sub 0 is the master and
193
00:09:57,197 --> 00:09:59,697
view controller sub 1 is the detail.
194
00:09:59,766 --> 00:10:01,632
Or sometimes we say the first thing in the array is
195
00:10:01,701 --> 00:10:04,469
the master and the last thing in the array is the detail.
196
00:10:04,538 --> 00:10:06,170
And if it's a navigationController, then
197
00:10:06,239 --> 00:10:08,806
viewController sub 0 is the rootViewController, and all of
198
00:10:08,875 --> 00:10:12,744
these cards lined on top are the other viewControllers
199
00:10:12,812 --> 00:10:15,079
in the array in order. So that's how you can get at all
200
00:10:15,147 --> 00:10:18,449
the viewControllers that are in one of the MVCs of MVCs.
201
00:10:18,518 --> 00:10:22,020
Now, how do you get at the MVC of MVCs itself?
202
00:10:22,088 --> 00:10:23,354
How do you get to the navigationController,
203
00:10:23,422 --> 00:10:24,756
the splitViewController, whatever?
204
00:10:24,825 --> 00:10:27,058
Well there's three awesome vars in UI view controller
205
00:10:27,127 --> 00:10:29,460
called tabBarController, splitViewController, and
206
00:10:29,528 --> 00:10:31,962
navigationController. And they will tell you the tabBar
207
00:10:32,031 --> 00:10:34,632
controller you're in, or the splitViewController you're
208
00:10:34,701 --> 00:10:37,401
in or the navigationController you're in. It might be in more
209
00:10:37,470 --> 00:10:40,037
than one, because you might be inside a navigationController
210
00:10:40,106 --> 00:10:42,373
as the master in a splitViewController.
211
00:10:42,441 --> 00:10:44,642
Which might even be in a tab of a tab bar controller, so
212
00:10:44,710 --> 00:10:47,045
you could be in all three of these things, and this will
213
00:10:47,113 --> 00:10:50,214
return what you're in. And so this way you can kinda get
214
00:10:50,283 --> 00:10:55,153
at the other MVCs that are involved in whatever
215
00:10:55,221 --> 00:10:58,723
combination of MVCs you have. So it's really good
216
00:11:00,193 --> 00:11:04,895
kind of access to things. Now navigationController,
217
00:11:04,964 --> 00:11:07,064
I wanna just briefly tell you about the API for
218
00:11:07,133 --> 00:11:09,200
it, it has a method pushViewController and
219
00:11:09,268 --> 00:11:11,636
popViewController, both can be animated. And
220
00:11:11,705 --> 00:11:14,973
that takes an MVC and puts it on the stack of your cars or
221
00:11:15,041 --> 00:11:17,908
popViewController pops the top one off. Okay,
222
00:11:17,977 --> 00:11:20,444
so you can do that pushing and popping, but we don't usually
223
00:11:20,513 --> 00:11:23,447
do it that way. We usually use what are called segues which
224
00:11:23,516 --> 00:11:25,884
I'm going to talk about in a moment here.
225
00:11:26,886 --> 00:11:27,751
All right, so
226
00:11:27,820 --> 00:11:30,488
how do we wire all of this stuff in our storyboard up?
227
00:11:30,557 --> 00:11:32,723
Okay, how do we get these navigationControllers, and
228
00:11:32,792 --> 00:11:33,791
splitViewControllers and
229
00:11:33,860 --> 00:11:36,594
tabBarControllers all hooked up to our MVCs? Okay, well
230
00:11:36,662 --> 00:11:39,964
of course we do it with Ctrl drag in the interface field,
231
00:11:40,033 --> 00:11:42,333
we do everything with Ctrl drag, right? Constraints,
232
00:11:42,401 --> 00:11:45,336
outlets, actions, all of these stuff with Ctrl drag, and
233
00:11:45,405 --> 00:11:47,605
we use Ctrl drag to do this as well. So
234
00:11:47,673 --> 00:11:50,208
let's look at an example of a splitViewController.
235
00:11:50,277 --> 00:11:52,076
If I wanted to have a couple of MVCs and
236
00:11:52,145 --> 00:11:53,344
set them as the master and
237
00:11:53,412 --> 00:11:55,279
the detail in splitViewController,
238
00:11:55,348 --> 00:11:57,748
I would just drag out a splitViewController from
239
00:11:57,817 --> 00:11:59,249
the same place I get a button or
240
00:11:59,318 --> 00:12:02,954
something. It will come with a bunch of extra VCs by the way,
241
00:12:03,023 --> 00:12:05,990
view controller is kind of, that it comes with for fun or
242
00:12:06,058 --> 00:12:08,827
for free. I'm not sure why it does it. We usually almost
243
00:12:08,895 --> 00:12:12,463
always just delete them. And then we Ctrl drag from
244
00:12:12,531 --> 00:12:15,666
the splitViewController to our master and we control drag