-
Notifications
You must be signed in to change notification settings - Fork 21
/
216 building adaptive apps with uikit [English].srt
4484 lines (3540 loc) · 84.4 KB
/
216 building adaptive apps with uikit [English].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:12,024 --> 00:00:16,033
either my name's Jacob Shaw and I'm
really excited to talk
2
00:00:17,014 --> 00:00:21,058
a about building adaptive aP's before we
get started though
3
00:00:21,058 --> 00:00:25,156
I wanna tell you what we mean by
adaptive the first
4
00:00:26,056 --> 00:00:30,025
let's go back in the beginning there
with the iPhone
5
00:00:30,529 --> 00:00:35,660
one device one screen was pretty simple
to build applications for
6
00:00:35,066 --> 00:00:38,105
but then when you consider rotation
7
00:00:38,699 --> 00:00:41,860
now you have this portrait and landscape
orientations
8
00:00:41,086 --> 00:00:44,144
and then after that we introduced the
iPad
9
00:00:45,044 --> 00:00:48,044
as well as the iPhone 45
10
00:00:48,044 --> 00:00:51,101
with its 4-inch display and I have all
these different
11
00:00:52,001 --> 00:00:56,014
devices and all these different screen
sizes and it can seem intimidating
12
00:00:56,014 --> 00:00:59,019
design aP's for well
13
00:00:59,019 --> 00:01:02,598
and I with eight we wanna make it simple
for you to build a
14
00:01:02,769 --> 00:01:06,000
to build one application that's both
universal
15
00:01:06,000 --> 00:01:09,085
and is able to adapt taller these
different devices
16
00:01:09,085 --> 00:01:13,120
screen sizes and orientations so today
17
00:01:14,002 --> 00:01:17,056
I like to tell you about the new
concepts that we've added
18
00:01:17,074 --> 00:01:20,079
for adaptivity inside you like it and
then
19
00:01:21,024 --> 00:01:24,099
we'll take a look at some of the changes
we've made to both you controllers
20
00:01:24,099 --> 00:01:27,548
and Interface Builder to support this
new adaptive world
21
00:01:28,439 --> 00:01:32,340
alright the start of let's take a look
22
00:01:32,034 --> 00:01:35,056
its size classes a new concept that
we've introduced
23
00:01:35,056 --> 00:01:38,142
and I with eight in the past
24
00:01:39,042 --> 00:01:43,047
used interface orientation and user
interface idiom
25
00:01:43,047 --> 00:01:47,085
to differentiate between portrait and
landscape an iPhone and iPad
26
00:01:47,085 --> 00:01:50,164
but Iowa State we're recommending
against using
27
00:01:51,064 --> 00:01:54,153
these two concepts and instead were
advocating
28
00:01:55,053 --> 00:01:59,099
this new concept the week off 55 balls
let me show I'll
29
00:01:59,099 --> 00:02:02,268
show you a little bit about what we mean
by these differences
30
00:02:03,159 --> 00:02:07,590
they represented by five class if you
think about
31
00:02:07,059 --> 00:02:10,088
a typical iPad application and the
screens that it shows
32
00:02:10,619 --> 00:02:14,780
you'll see features like split view
controllers form sheets
33
00:02:14,078 --> 00:02:17,114
and popovers but really
34
00:02:18,014 --> 00:02:22,613
none of these features are specific to
the iPad itself we're just using these
35
00:02:22,739 --> 00:02:26,390
in this app in this iPad version of the
application we have because we have this
36
00:02:26,039 --> 00:02:27,116
large horizontal campus
37
00:02:28,016 --> 00:02:31,072
the display with them now on the other
hand
38
00:02:31,072 --> 00:02:33,166
if you look at a typical iPhone
application you have a much more
39
00:02:34,066 --> 00:02:35,087
constrained layout
40
00:02:35,087 --> 00:02:39,096
where things are usually presented
fullscreen and shown in a single column
41
00:02:39,879 --> 00:02:43,943
however this is also not intrinsically
tied to the fact that it's an iPhone
42
00:02:44,519 --> 00:02:47,730
this just a tied to the fact that we
have this
43
00:02:47,073 --> 00:02:51,075
smaller scores of appendicitis you'll
see the same kind of thing
44
00:02:51,093 --> 00:02:54,134
and the master side us but you
controller
45
00:02:55,034 --> 00:02:58,433
and even in the content a popover
46
00:02:58,739 --> 00:03:03,430
and both movies on iPad so we call this
difference
47
00:03:03,043 --> 00:03:08,132
regular and compact and we call this
48
00:03:08,519 --> 00:03:12,522
access the horizontal side class now
49
00:03:12,819 --> 00:03:16,220
if we consider the same kinda
distinctions in the vertical direction
50
00:03:16,022 --> 00:03:19,034
you can see that on things like an iPad
or an
51
00:03:19,034 --> 00:03:22,106
our night phone we have these taller
full-size bars
52
00:03:23,006 --> 00:03:26,295
whereas in a more constrained vertical
situation
53
00:03:26,349 --> 00:03:30,310
like an iPhone in landscape we have both
convinced bars
54
00:03:30,031 --> 00:03:33,430
and now and I with aid we even hide the
status bar completely
55
00:03:33,709 --> 00:03:37,090
and we call these also regular
56
00:03:37,009 --> 00:03:40,022
and compact but this time in the
vertical
57
00:03:40,022 --> 00:03:44,078
five-plus now you can think that these
two sides classes
58
00:03:44,078 --> 00:03:47,082
in a similar way the way size works just
like a size
59
00:03:48,018 --> 00:03:52,037
has a horizontal and vertical dimension
so does the size class
60
00:03:52,037 --> 00:03:55,436
so if you put these two concepts
together
61
00:03:55,769 --> 00:03:59,090
you get a two by two grid that defines
62
00:03:59,009 --> 00:04:02,023
and you've the possibilities a regular
and compact
63
00:04:02,023 --> 00:04:06,342
in both the horizontal and vertical
directions and you can have a view
64
00:04:06,549 --> 00:04:06,624
controller
65
00:04:07,299 --> 00:04:11,140
with any of these four possibilities
which results in different layouts
66
00:04:11,014 --> 00:04:15,106
like it see here in addition to view
controllers having any of these
67
00:04:16,006 --> 00:04:19,051
aside class combinations our devices
also have
68
00:04:19,051 --> 00:04:23,077
default five passes that they'll that
they'll use an iPad
69
00:04:23,077 --> 00:04:27,139
in both landscape and portrait will have
a regular size class and both horizontal
70
00:04:28,039 --> 00:04:29,061
and vertical direction
71
00:04:29,061 --> 00:04:32,126
an iPhone women portrait
72
00:04:33,026 --> 00:04:36,095
will have a compact core sample size
class
73
00:04:36,095 --> 00:04:40,100
and a regular vertical size class and
went to landscape
74
00:04:41,000 --> 00:04:44,013
it will be compact in both the vertical
and horizontal
75
00:04:44,013 --> 00:04:48,055
five passes so this is all a little
theoretical
76
00:04:48,055 --> 00:04:50,137
let's take a look at a sample
application to see how this works in
77
00:04:51,037 --> 00:04:52,041
practice
78
00:04:52,077 --> 00:04:55,120
all right so the sample code that I'll
be showing you today
79
00:04:56,002 --> 00:04:59,002
is available on the WWDC website
80
00:04:59,002 --> 00:05:02,651
just go to the sample code section and
search for adaptive photos
81
00:05:02,849 --> 00:05:06,923
the name of our sample app it's a basic
photo sharing application
82
00:05:07,589 --> 00:05:11,590
and this is what it looks like on iphone
you can see our list
83
00:05:11,599 --> 00:05:14,860
our contacts and I can tap on any of
these
84
00:05:14,086 --> 00:05:18,124
to see the photos that they've set sent
back to me
85
00:05:19,024 --> 00:05:23,433
if someone is only sent me a single
photo I'll go directly to that image
86
00:05:23,649 --> 00:05:27,180
and if they sent me multiple photos I
get the list at the photos that they
87
00:05:27,018 --> 00:05:28,023
sent me
88
00:05:28,068 --> 00:05:33,075
and then view individual ones
89
00:05:33,075 --> 00:05:36,138
now on the photo page you'll notice that
in addition to the picture
90
00:05:37,038 --> 00:05:40,137
were also showing a comment overlay and
a reading control
91
00:05:41,037 --> 00:05:45,074
let me write the photos that they sent
me
92
00:05:45,074 --> 00:05:49,053
alright now when I rotate this
application to landscape
93
00:05:49,719 --> 00:05:53,120
notice that are bars become condensed
and the status bar
94
00:05:53,012 --> 00:05:57,014
disappears entirely
95
00:05:57,014 --> 00:06:00,038
this all happens automatically but in
our application
96
00:06:00,038 --> 00:06:03,130
we've done a few more customizations
inside a photo view
97
00:06:04,003 --> 00:06:07,010
when I wrote a the the
98
00:06:07,037 --> 00:06:10,108
not comments will have a smaller margins
and the rain control
99
00:06:11,008 --> 00:06:16,064
will shrink down to a smaller size
100
00:06:16,064 --> 00:06:19,403
now our application is of course
universal
101
00:06:19,979 --> 00:06:26,979
so let me run it and side at the iPad
simulator
102
00:06:27,056 --> 00:06:33,655
here you notice that I have all the same
functionality
103
00:06:34,159 --> 00:06:37,640
and all the same controls inside my
photo view
104
00:06:37,064 --> 00:06:40,093
but watch when I rotate to landscape
105
00:06:40,093 --> 00:06:43,119
all the bars have still have the full
height
106
00:06:44,019 --> 00:06:47,101
and I love my controls here have shut
down miss it because we still have this
107
00:06:48,001 --> 00:06:49,830
large vertical real estate
108
00:06:49,839 --> 00:06:53,320
and in our application we're using the
vertical five class
109
00:06:53,032 --> 00:06:56,074
instead of the interface orientation so
we get the right behavior
110
00:06:56,074 --> 00:07:00,081
on both iPhone and iPad
111
00:07:01,044 --> 00:07:05,107
now one of the new features we batted an
eye with a is a resizable simulator
112
00:07:06,007 --> 00:07:09,058
so if you notice here at the bottom I
can type in
113
00:07:09,058 --> 00:07:16,058
new dimensions
114
00:07:16,599 --> 00:07:20,620
and you'll see the my application has
resized and everything still looks great
115
00:07:20,062 --> 00:07:24,088
because we're using auto layout insists
that standard system components
116
00:07:24,088 --> 00:07:27,927
but in addition to just changing size I
can also change
117
00:07:28,719 --> 00:07:33,300
the psych class and now
118
00:07:33,003 --> 00:07:36,079
you'll see they were showing the iPhone
version of our application even on the
119
00:07:37,006 --> 00:07:37,735
iPad
120
00:07:37,789 --> 00:07:44,789
just by changing the side bus
121
00:07:45,024 --> 00:07:48,493
so I highly recommend you test out your
application with the new
122
00:07:48,709 --> 00:07:54,770
recital simulator and I with a
123
00:07:54,077 --> 00:07:57,125
alright so now the you know how five
passes work in general
124
00:07:58,025 --> 00:08:01,554
how do you actually get one at the site
classes in your application
125
00:08:01,779 --> 00:08:05,818
what to do that use the new system we
call traits
126
00:08:06,169 --> 00:08:09,262
traits are essentially properties that
you can use to determine how
127
00:08:10,099 --> 00:08:16,116
the layout your application should
change at the environment changes
128
00:08:16,269 --> 00:08:20,271
they consist a set a property's
including the horizontal and vertical
129
00:08:20,289 --> 00:08:22,830
five classes that we just talked about
130
00:08:22,083 --> 00:08:26,182
as well as the user interface idiom and
also the display scale
131
00:08:27,082 --> 00:08:30,130
now all these traits a wrapped up inside
a container
132
00:08:31,003 --> 00:08:34,062
we call I a tree collection this
includes
133
00:08:34,089 --> 00:08:39,038
the trade properties and also their
values
134
00:08:39,839 --> 00:08:43,841
and this new object is called you I
tried collection
135
00:08:44,039 --> 00:08:48,550
you wanted the street collections you
just need to use a trade environment
136
00:08:48,055 --> 00:08:51,078
train by Mansur our new protocol better
able
137
00:08:51,078 --> 00:08:54,119
to return their current trick collection
and these include
138
00:08:55,019 --> 00:08:58,104
screens Windows you controllers
139
00:08:59,004 --> 00:09:02,099
and also views all these are able to
return
140
00:09:02,099 --> 00:09:05,174
the current rate collection to you to
use to determine how your interface
141
00:09:06,074 --> 00:09:08,110
should be laid out
142
00:09:09,001 --> 00:09:12,042
one other object that's also a trade
environment is a you at presentation
143
00:09:12,051 --> 00:09:13,057
controller
144
00:09:14,011 --> 00:09:18,016
this is a new helper object that assists
with you control a presentation
145
00:09:18,061 --> 00:09:21,149
and it's also able to park participate
and adaptivity
146
00:09:22,049 --> 00:09:25,076
we don't have time to talk about today
about presentation controllers
147
00:09:25,076 --> 00:09:28,076
but you can come back tomorrow at 11:30
to the
148
00:09:28,076 --> 00:09:31,088
a look inside presentation controllers
talk to learn more
149
00:09:31,088 --> 00:09:34,127
about how presentation controllers work
including how the
150
00:09:35,027 --> 00:09:39,044
work with traits and adaptivity
151
00:09:39,044 --> 00:09:44,102
now all these trained by romance make up
a hierarchy
152
00:09:45,002 --> 00:09:49,046
and the trick elections that they have
will flow from parent to child
153
00:09:49,046 --> 00:09:53,091
so by default the track elections at any
given child trig environment has
154
00:09:53,091 --> 00:09:57,103
will be the ones that it inherited from
its parent all the way up to the screen
155
00:09:58,003 --> 00:10:02,027
which makes up the route treatment
156
00:10:02,027 --> 00:10:05,088
now in addition to getting the current
recollection from train varmint
157
00:10:05,088 --> 00:10:09,151
they also have another method and that's
tree collection did change
158
00:10:10,051 --> 00:10:13,066
this gets called whenever the traits
forgiven trade environment
159
00:10:13,066 --> 00:10:16,107
are have just changed you can override
this
160
00:10:17,007 --> 00:10:20,031
in your view controller or view subclass
snow
161
00:10:20,031 --> 00:10:23,056
when you should be changing I love your
UI elements
162
00:10:23,056 --> 00:10:28,056
that depend on traits and was even an
example that a little bit later
163
00:10:28,056 --> 00:10:31,083
in our sample application
164
00:10:31,083 --> 00:10:34,083
now let's take a look at a typical trade
collection
165
00:10:34,083 --> 00:10:37,171
the street collection is one you might
see on an iPhone in portrait
166
00:10:38,071 --> 00:10:42,140
we have a compact or sample size class a
regular vertical side class
167
00:10:43,004 --> 00:10:46,065
idioma phone and at this point scale up
to
168
00:10:47,001 --> 00:10:50,075
we call this a fully specified trade
collection because it has values for all
169
00:10:50,075 --> 00:10:52,099
its straight properties
170
00:10:52,099 --> 00:10:56,193
out of a possible have a tree collection
that's missing some up its values
171
00:10:57,093 --> 00:11:00,135
and we call these missing values
unspecified
172
00:11:01,035 --> 00:11:04,098
generally though when you ask the train
environment for trade collection
173
00:11:04,098 --> 00:11:08,120
you go back a fully specified track
collection like the one on the left
174
00:11:09,002 --> 00:11:12,025
however if a train by meant like a view
our view controller
175
00:11:12,043 --> 00:11:15,051
is not inside the view hierarchy you
might get back
176
00:11:15,051 --> 00:11:19,058
unspecified values like the track
collection on the road
177
00:11:19,058 --> 00:11:22,071
you also get back these partially
specified take elections
178
00:11:22,071 --> 00:11:25,138
if you create your own trick collection
using one of our creation methods
179
00:11:26,038 --> 00:11:29,082
like trade collection with horizontal
five-plus which would allow you to
180
00:11:29,082 --> 00:11:33,103
create a tree collection just like the
one on the right
181
00:11:34,003 --> 00:11:37,056
now one operation that we can perform on
multiple trait collections
182
00:11:37,056 --> 00:11:41,077
is comparing them to each other and
comparing a trick collection
183
00:11:41,077 --> 00:11:46,081
involves asking if one tree collection
contains another one
184
00:11:46,081 --> 00:11:49,124
now what this means about containment is
that for any trade
185
00:11:50,024 --> 00:11:53,056
thats specified in the Fed second tree
collection
186
00:11:53,056 --> 00:11:56,104
the value at that rate in the first
recollection has to have the same to
187
00:11:57,004 --> 00:12:00,097
has two match exactly so here the second
track collection
188
00:12:00,097 --> 00:12:03,143
only has a specified or sample size
class
189
00:12:04,043 --> 00:12:07,112
and this this horizontal side cuts are
equal so we'd say that the first rate
190
00:12:08,012 --> 00:12:10,018
collection contains the second one
191
00:12:10,072 --> 00:12:13,100
and the way you can ask this question
the up trick collections
192
00:12:14,000 --> 00:12:19,044
is by using the contains traits Inc
Lexion method on you at recollection
193
00:12:19,044 --> 00:12:22,055
if we were to change the for example
size bass at the second track election
194
00:12:22,055 --> 00:12:23,113
to regular
195
00:12:24,013 --> 00:12:27,088
you can see that now these two
horizontal size classes don't match
196
00:12:27,088 --> 00:12:33,161
so second take: collection is no longer
contain by the first one
197
00:12:34,061 --> 00:12:37,085
now you can perform these comparisons
yourself in your own code
198
00:12:37,085 --> 00:12:41,096
to determine how you should lay out your
user view controllers
199
00:12:41,096 --> 00:12:44,138
but you like it also uses this
internally for some
200
00:12:45,038 --> 00:12:48,044
for some of its functionality and one
example of that
201
00:12:48,098 --> 00:12:51,155
is the appearance proxy the Prince proxy
is a system
202
00:12:52,055 --> 00:12:55,057
that we introduced a while ago for
customizing
203
00:12:55,057 --> 00:12:59,148
the properties up your views and with
extended it and I was 8
204
00:13:00,048 --> 00:13:03,090
to support recollections we now have a
new method
205
00:13:03,009 --> 00:13:07,071
appearance for trait collection they
returned you a new appearance proxy
206
00:13:08,052 --> 00:13:12,065
with a given trait collection that you
passed in any customization
207
00:13:12,065 --> 00:13:15,070
the you perform on that appearance proxy
will only
208
00:13:16,015 --> 00:13:19,069
take a fact on views better that
209
00:13:19,069 --> 00:13:22,100
they conform to that take much in the