-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path16. Alerts and Action Sheets, Notifications, Application Lifecycle, and Persistence.srt
7972 lines (6378 loc) · 183 KB
/
16. Alerts and Action Sheets, Notifications, Application Lifecycle, and Persistence.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
00:00:00,401 --> 00:00:04,536
[MUSIC]
2
00:00:04,605 --> 00:00:07,439
Stanford University,
斯坦福大学,
3
00:00:07,508 --> 00:00:11,676
>> Welcome to Stanford CS193P, Developing Applications for
> >欢迎来到斯坦福CS193P,开发应用程序
4
00:00:11,745 --> 00:00:13,378
iOS, Winter 2017,
iOS,2017年冬天,
5
00:00:13,447 --> 00:00:15,280
This is lecture number 16,
这是16号讲
6
00:00:15,349 --> 00:00:18,883
We have some miscellaneous topics today, all of which I
今天我们有一些各种各样的话题,所有的我
7
00:00:18,952 --> 00:00:23,221
think might be interesting to you for your final projects,
认为可能是有趣的,你的最后一个项目,
8
00:00:23,290 --> 00:00:25,390
We're gonna talk about alerts and
我们会谈论警报和
9
00:00:25,459 --> 00:00:28,226
alert's cousin: action sheet,
警报的表亲:动作表单,
10
00:00:28,295 --> 00:00:30,095
We'll talk about notifications,
我们将讨论通知,
11
00:00:30,163 --> 00:00:32,497
that's the radio station model from our MVC,
这是电台从我们的MVC模型,
12
00:00:32,566 --> 00:00:34,399
We'll talk about the application lifecycle: we
我们将讨论应用程序生命周期:我们
13
00:00:34,468 --> 00:00:36,101
already talked about the lifecycle of view,
已经讨论过的生命周期来看,
14
00:00:36,170 --> 00:00:38,103
but now we're gonna talk about the lifecycle of
但是现在我们要讨论的生命周期
15
00:00:38,171 --> 00:00:39,204
the whole application,
整个应用程序,
16
00:00:39,273 --> 00:00:41,373
And finally I'm gonna talk about persistence,
最后我要讲的持久性,
17
00:00:41,442 --> 00:00:42,674
How do we store stuff so
我们商店的东西怎么样
18
00:00:42,743 --> 00:00:44,976
that when our app launches it finds it and
当我们的应用程序启动它发现它
19
00:00:45,045 --> 00:00:48,113
of course you already know a couple ways of doing that,
当然,你已经知道的几个方法做,
20
00:00:48,182 --> 00:00:51,883
So I'm just gonna show you a couple others,
所以我要给你们几个,
21
00:00:51,951 --> 00:00:55,687
Let's start with this alerts and action sheets business,
让我们从这开始警报和行动表业务,
22
00:00:55,755 --> 00:00:57,188
These are "pop up and
这些都是“流行起来
23
00:00:57,257 --> 00:01:01,125
ask the user a question" kind of user interfaces,
要求用户一种问题”的用户界面,
24
00:01:01,194 --> 00:01:04,963
They're both just MVCs, alert and action sheet is just
他们都只是mvc,警报和动作表单是公正的
25
00:01:05,031 --> 00:01:08,533
an MVC, and they're always presented modally or in
MVC,他们总是模式地展示或
26
00:01:08,602 --> 00:01:12,771
a popover, which as we learned last time is basically modal,
弹窗,正如我们上次学基本上是模态的,
27
00:01:12,840 --> 00:01:15,974
So alerts pop up in the middle of the screen,
所以警报出现在屏幕的中间,
28
00:01:16,043 --> 00:01:20,345
they usually ask questions with only two answers,
他们通常只有两个答案,提问
29
00:01:20,414 --> 00:01:23,614
Like yes or no, OK and Cancel,
像“是”或“否”,可以取消,
30
00:01:23,683 --> 00:01:27,352
It is okay to have an alert I guess with just an OK button,
是好的一个警告我想只有一个OK按钮,
31
00:01:28,789 --> 00:01:31,890
Usually you wanna maybe think of if there's a better way to
通常你想也许想到如果有更好的方法
32
00:01:31,959 --> 00:01:35,727
present that information to the user than putting up
比将向用户显示信息
33
00:01:35,796 --> 00:01:37,313
And then we start talking about having three answers
然后我们开始讨论有三个答案
34
00:01:37,314 --> 00:01:38,831
an alert,
一个警告,
35
00:01:38,899 --> 00:01:40,231
in alert,
在警报,
36
00:01:40,300 --> 00:01:42,267
(A) you might wanna think about an action sheet,
(一)你可能想考虑一个动作表单,
37
00:01:42,335 --> 00:01:43,869
which I'll talk about in a second,
我将讨论在第二个,
38
00:01:43,937 --> 00:01:46,604
And (B) you just might wanna think about how am I getting
和(B)你可能想考虑我
39
00:01:46,673 --> 00:01:49,374
the user in the situation where I'm asking them
用户的情况,我问他们
40
00:01:49,442 --> 00:01:50,708
an emergency question,
一个紧急的问题,
41
00:01:50,777 --> 00:01:52,844
and there's three different answers or
和有三个不同的答案
42
00:01:52,913 --> 00:01:56,347
even more than three, that would really be interesting,
甚至超过三个,真的很有趣,
43
00:01:56,416 --> 00:01:58,550
So, alerts are quite disruptive to the UI,
所以,警报非常破坏UI,
44
00:01:58,618 --> 00:02:01,119
The user is happily using their user interface and
用户使用他们的用户界面和幸福
45
00:02:01,188 --> 00:02:03,955
then bam, the whole screen goes grey and there's this
然后bam,整个屏幕是灰色的
46
00:02:04,023 --> 00:02:07,693
little box in the middle and it's giving them some alert,
小盒子中间,给他们一些警告,
47
00:02:07,761 --> 00:02:10,595
I saw a class forum post about using alert, and there was
我看见一个类论坛帖子关于使用警报,有
48
00:02:10,664 --> 00:02:13,398
a great suggestion there from one of the TAs which is,
一个伟大的建议从一个助教的,
49
00:02:13,467 --> 00:02:16,467
this is something you wanna read the Apple human interface
这是你想要看苹果的人机界面
50
00:02:16,536 --> 00:02:19,137
guidelines about using alerts, when to use them,
指南使用警报、何时使用它们
51
00:02:19,206 --> 00:02:21,306
what to say in alert, things like that,
在警报,说点什么,
52
00:02:21,374 --> 00:02:24,309
And in fact, I recommend all of you read the human
事实上,我建议你读了所有的人
53
00:02:24,378 --> 00:02:26,912
interface guidelines from Apple in general, so
界面指南从苹果一般
54
00:02:26,980 --> 00:02:30,281
I'm gonna post that on the class forum, the link to that,
我要在类论坛帖子,链接,
55
00:02:30,350 --> 00:02:33,484
And I'm actually going to hold you to it in
和我要抱着你
56
00:02:33,553 --> 00:02:35,954
the UI part of the rubric in your final project,
UI的一部分标题在你最后的项目中,
57
00:02:36,022 --> 00:02:39,157
So pay some close attention to that, Apple's done
所以一些密切关注,苹果的完成
58
00:02:39,226 --> 00:02:42,694
a really good job of analyzing all the uses of the various UI
很好地分析所有的使用不同的UI
59
00:02:42,762 --> 00:02:46,164
elements and kind of what works well, what doesn't work
元素和类型的什么是有效的,什么是行不通的
60
00:02:46,233 --> 00:02:50,568
so well, and what's consistent between different things so,
很好,不同的东西之间的一致,
61
00:02:50,637 --> 00:02:54,773
An alert can ask the user for a little bit of text,
警报可以要求用户输入一些文本,
62
00:02:54,842 --> 00:02:57,675
This has been abused to
这是虐待
63
00:02:57,744 --> 00:03:01,613
make like login screens out of alerts and things like that,
做像登录屏幕警报之类的东西,
64
00:03:01,681 --> 00:03:04,382
It's pretty rare in my experience that you actually
它在我的经验,你真的很罕见
65
00:03:04,451 --> 00:03:06,951
wanna ask for text in an alert, but I'll show you in
对文本警报想问,但我将向您展示
66
00:03:07,020 --> 00:03:10,989
the demo today how to do it, but it's pretty unusual,
今天的演示怎么做,但它很不寻常,
67
00:03:11,058 --> 00:03:13,792
And then there's action sheets,
然后有行动表,
68
00:03:13,861 --> 00:03:16,895
now an action sheet does not gray out the whole screen and
现在动作表单没有灰色了整个屏幕
69
00:03:16,964 --> 00:03:17,796
appear in a little box,
出现在一个小盒子,
70
00:03:17,864 --> 00:03:21,466
instead on an iPhone it slides up from the bottom,
而不是在iPhone幻灯片从底部,
71
00:03:21,534 --> 00:03:24,303
And on an iPad, it's always gonna pop over,
在iPad上,它总是会流行,
72
00:03:25,905 --> 00:03:29,174
Now, an action sheet, I like to think of as
现在,动作表单,我喜欢的
73
00:03:29,242 --> 00:03:32,477
a branching decision user interface element,
一个分支决策用户界面元素,
74
00:03:32,546 --> 00:03:35,781
So a user has gotten to some point in the UI where you
所以用户已经在你的UI
75
00:03:35,849 --> 00:03:38,883
simply can't really proceed without knowing
无法真的不知道
76
00:03:38,952 --> 00:03:40,619
what the user wants to do,
用户想要做什么,
77
00:03:40,687 --> 00:03:44,323
So for an example: maybe you want to include an image in
所以对于一个例子:也许你想要包括一个图像
78
00:03:44,391 --> 00:03:45,524
something,
什么东西,
79
00:03:45,593 --> 00:03:48,593
A contact, and it's the profile image, or
一个联系人,这个概要文件的形象,或
80
00:03:48,662 --> 00:03:50,195
something like that,
类似的,
81
00:03:50,263 --> 00:03:52,630
And do you want that image to come from the camera,
和你想要图片来自相机,
82
00:03:52,699 --> 00:03:55,200
where it's gonna take a picture right now?
现在,它会拍照吗?
83
00:03:55,269 --> 00:03:58,002
Or from the photo library, past photos you've taken?
或从照片库、过去的照片你了?
84
00:03:58,071 --> 00:04:01,773
Or maybe from some collection view of clip art or something,
或者从某种集合视图的剪贴画,
85
00:04:01,842 --> 00:04:05,076
avatars or whatever that you provide, so you've kind of got
头像什么的,你提供,所以你得到的
86
00:04:05,145 --> 00:04:08,146
to go in one of these three directions so an active sheet
去其中的一个方向,所以一个活跃的表
87
00:04:08,215 --> 00:04:11,549
might slide up from the bottom and say you know add photo,
可能会从底部滑上来,说你知道添加照片,
88
00:04:11,618 --> 00:04:14,386
how do you wanna do it and you get these choices,
你想怎么做,你把这些选择,
89
00:04:14,454 --> 00:04:18,323
And usually there's Cancel also which is I didn't mean to
通常也有取消我不是故意的
90
00:04:18,392 --> 00:04:19,857
do that so cancel,
所以取消,
91
00:04:19,926 --> 00:04:23,795
Action usually have more then two answers,
行动通常有超过两个答案,
92
00:04:23,863 --> 00:04:27,198
It wouldn't be wrong necessarily to have an action
它不会是错的一定要有行动
93
00:04:27,267 --> 00:04:29,167
sheet with only two answers but
但表只有两个答案
94
00:04:29,235 --> 00:04:32,404
it just rarely does that circumstance arise,
只是很少出现这样的情况,
95
00:04:33,506 --> 00:04:35,440
So what do these two things look like?
这两个东西看起来像什么?
96
00:04:35,509 --> 00:04:37,909
This is what an action sheet looks like on an iPhone,
这是一个行动表看起来像在iPhone上,
97
00:04:37,978 --> 00:04:41,012
You see how it slides up from the bottom there and it has
你看到它如何从底部那里幻灯片,
98
00:04:41,080 --> 00:04:44,482
some choices in it and this is what an alert looks like,
一些选择,这是一个警告是什么样子,
99
00:04:44,551 --> 00:04:46,151
It takes over the whole screen,
它接管整个屏幕,
100
00:04:46,219 --> 00:04:48,987
This one happens to have a little text field in it,
这个恰好有一个文本字段,
101
00:04:49,056 --> 00:04:51,222
with two choices there,
有两个选择,
102
00:04:51,291 --> 00:04:52,524
So let's talk about the API,
所以让我们来谈谈API,
103
00:04:52,592 --> 00:04:54,893
To make these work because it's the exact same API,
做这些工作,因为它是相同的API,
104
00:04:54,961 --> 00:04:57,829
in fact it's the same MBC that does both of them,
事实上MBC是一样的,他们两人,
105
00:04:59,099 --> 00:05:02,567
This is the API to create this view controller,
这是API创建这个视图控制器,
106
00:05:02,636 --> 00:05:04,669
it's called a UI alert controller, and
它被称为一个UI警报控制器
107
00:05:04,738 --> 00:05:06,705
it just has a title, which is that thing at the top,
它有一个标题,在顶部,
108
00:05:06,774 --> 00:05:08,940
you see where it says redeploy Cassini,
你看到它重新部署卡西尼说,
109
00:05:09,008 --> 00:05:11,509
In the picture on the left there, that's the title,
在左边的图片,标题,
110
00:05:11,578 --> 00:05:14,545
And then message is just a short informational message
然后消息只是一个简短的信息消息
111
00:05:14,614 --> 00:05:17,081
telling you what the heck is going on right now,
告诉你现在到底是怎么回事,
112
00:05:17,150 --> 00:05:19,084
And then preferred style right there,
然后选择风格,
113
00:05:19,152 --> 00:05:22,354
if you set that to action sheet you get an action sheet,
如果你设置动作表单动作表单,
114
00:05:22,422 --> 00:05:24,622
If you set it to ,alert you're going to get an alert and
如果你把它,提醒你会得到一个警告
115
00:05:24,691 --> 00:05:25,523
I'll show you that,
我将向您展示,
116
00:05:25,592 --> 00:05:28,894
So the API for these is basically identical except for
所以对这些基本上是相同的除了API
117
00:05:28,962 --> 00:05:32,997
this one little preferred style thing right there,
这个小喜欢的风格的东西,
118
00:05:33,066 --> 00:05:35,733
So once you've created your alert, you wanna add buttons,
所以一旦你创建警报,你想添加按钮,
119
00:05:35,802 --> 00:05:39,103
Now adding buttons to your alert or action sheet,
现在将按钮添加到你的警报或动作表单,
120
00:05:39,172 --> 00:05:40,805
is done with add action,
完成添加操作,
121
00:05:40,874 --> 00:05:45,677
And the argument to add action is a UI alert action object,
和添加操作的参数是一个UI警报操作对象,
122
00:05:45,746 --> 00:05:48,580
And UIAlertAction is created with a title,
和创建UIAlertAction标题,
123
00:05:48,648 --> 00:05:51,149
So that's the title of the button,
这是按钮的标题,
124
00:05:51,217 --> 00:05:53,752
A style, and we'll talk about what all the styles,
风格,我们将讨论所有的风格,
125
00:05:53,820 --> 00:05:54,952
the button styles are,
按钮样式,
126
00:05:55,021 --> 00:05:56,020
And then a handler,
然后一个处理程序,
127
00:05:56,089 --> 00:05:58,890
Now, this handler is just a closure that you provide,
现在,这个处理程序只是提供一个闭包,
128
00:05:58,959 --> 00:06:01,592
This is the handler that's gonna get executed if that
这是处理程序的执行
129
00:06:01,661 --> 00:06:04,162
button is pressed, so that's the model for
按钮被按下,这样的模型
130
00:06:04,231 --> 00:06:05,864
alerts, it couldn't be simpler,
警报、不可能是简单的
131
00:06:05,932 --> 00:06:08,933
So let's look in example one, we got Orbit Saturn right
让我们看一个例子,我们得到了土星轨道
132
00:06:09,002 --> 00:06:11,102
there, see the title is Orbit Saturn,
看到标题是土星轨道,
133
00:06:11,171 --> 00:06:14,773
The style, this style is called ,default,
的风格,这种风格,默认情况下,
134
00:06:14,841 --> 00:06:18,376
So the default style, the text is gonna not be red, okay,
所以默认风格,文本会不会红,好吧,
135
00:06:18,444 --> 00:06:21,646
it's gonna be whatever color you've got going on in
它会发生的任何颜色你有
136
00:06:21,715 --> 00:06:23,648
your app there, usually blue,
你的应用,通常是蓝色的,
137
00:06:23,716 --> 00:06:26,684
And then in my closure here, this orbits Saturn, so
然后在我关闭这里,这个轨道土星,所以
138
00:06:26,753 --> 00:06:29,287
I'm gonna just go into orbit around Saturn,
我要进入环绕土星的轨道上,
139
00:06:29,356 --> 00:06:32,556
That's Cassini's mission by the way, to go to orbit around
这是卡西尼号的使命,去绕
140
00:06:32,625 --> 00:06:36,160
Saturn, so it's just going to do it, if I click that button,
土星,所以要这样做,如果我点击那个按钮,
141
00:06:36,229 --> 00:06:38,096
And let's add another button,
让我们添加一个按钮,
142
00:06:38,164 --> 00:06:41,132
this one's explore Titan, a moon out there,
这是探索泰坦,月亮,
143
00:06:41,200 --> 00:06:44,101
This is a little bit outside, well it's inside Cassini's
这一点外,在卡西尼号的
144
00:06:44,170 --> 00:06:45,804
mission but before we divert it,
任务在我们转移之前,
145
00:06:45,872 --> 00:06:48,373
we wanna make sure we're gonna log in for example,
我们要确保我们会登录为例,
146
00:06:48,442 --> 00:06:50,509
So here in my closure you see I've logged in,
所以在我关闭你看到我登录,
147
00:06:50,577 --> 00:06:53,244
made sure I'm logged in before I go to type,
让我我去之前登录类型,
148
00:06:53,313 --> 00:06:54,212
But it's the same kind of thing,
但这是同样的事情,
149
00:06:54,281 --> 00:06:56,615
a default button right there,
一个默认按钮,
150
00:06:56,683 --> 00:06:58,149
All right, so we've got those two default buttons,
好了,所以我们有这两个默认按钮,
151
00:06:58,218 --> 00:06:59,183
the blue ones,
蓝色的,
152
00:06:59,252 --> 00:07:02,854
How about that closeup of sun button,
特写镜头的阳光按钮,
153
00:07:02,923 --> 00:07:05,190
Now if Cassini closed up to the sun,
现在,如果卡西尼号关闭了太阳,
154
00:07:05,259 --> 00:07:08,259
it will be destroyed cuz it doesn't have enough
它将被破坏,因为它没有足够的
155
00:07:08,328 --> 00:07:11,529
propulsion to escape the sun gravity well there,
推进摆脱太阳引力井,
156
00:07:11,598 --> 00:07:15,132
So I made the style of this button be ,destructive,
所以我做了这个按钮的风格是破坏性的,
157
00:07:15,201 --> 00:07:16,801
instead of ,default,
相反的,默认情况下,
158
00:07:16,869 --> 00:07:20,004
And so ,destructive in an action sheet is gonna turn in
因此,表会在破坏性的行动
159
00:07:20,073 --> 00:07:22,540
turn up red okay just so that the user knows "
出现红色好这样用户知道”
160
00:07:22,609 --> 00:07:25,977
this one is probably something I should be carefully with",
这个可能是我应该仔细”,
161
00:07:26,046 --> 00:07:28,446
And anytime you have a destructive action in your
并在你任何时候你有一个破坏性的行动
162
00:07:28,514 --> 00:07:31,382
closure, you are probably going to want to confirm that
关闭,你可能会想确认
163
00:07:31,451 --> 00:07:33,918
this really want do to that destructive action,
这真的要做破坏性的行动,
164
00:07:33,987 --> 00:07:37,188
In this case, for example I'm gonna make them log in again
在这种情况下,例如我要让他们再次登录
165
00:07:37,257 --> 00:07:38,722
or something like that,
之类的,
166
00:07:38,791 --> 00:07:40,157
So that's destructive, and
这是破坏性的
167
00:07:40,226 --> 00:07:42,893
then finally we've got the cancel button at the bottom,
最后我们有取消按钮在底部,
168
00:07:42,962 --> 00:07:45,530
that's another type of button called Cancel style and
这是另一种类型的按钮叫风格和取消
169
00:07:45,599 --> 00:07:47,999
you can see that it looks a little different right,
你可以看到它看起来有点不同吧,
170
00:07:48,067 --> 00:07:50,435
it's kinda separated from the other buttons,
其他的纽扣有点分开,
171
00:07:50,503 --> 00:07:52,604
It's not destructive in fact it's the opposite of
这不是破坏性的实际上是相反的
172
00:07:52,672 --> 00:07:56,007
destructive, it gets you out of the problem,
破坏性的,它能让你的问题,
173
00:07:56,075 --> 00:07:56,974
Of this action sheet,
这个动作表单,
174
00:07:57,043 --> 00:07:58,609
to go back to wherever you were before,
回到无论你之前,
175
00:07:58,678 --> 00:08:01,079
you're not really gonna redeploy Cassini,
你不是真的要重新部署“卡西尼”号,
176
00:08:01,148 --> 00:08:03,014
And, but it is separated down there,
但它是分离,
177
00:08:03,083 --> 00:08:05,350
It kind of gives it just a little bit of a highlight,
它给它一点点的一大亮点,
178
00:08:08,655 --> 00:08:10,988
So I've added all my actions, I've got my buttons, and
我添加了我所有的行动,我有我的按钮,
179
00:08:11,057 --> 00:08:15,026
now I want to make this action sheet appear on screen,
现在我想让这个动作表单出现在屏幕上,
180
00:08:15,095 --> 00:08:17,495
And I do that with the normal method that
和我正常的方法
181
00:08:17,564 --> 00:08:20,031
we talked about before, which is present,
我们之前讲过,这是礼物,
182
00:08:20,099 --> 00:08:24,201
Remember, present is a view controller method that just
记住,现在只是一个视图控制器方法
183
00:08:24,270 --> 00:08:28,172
presents the new controller using whatever modal
提出了新的控制器使用任何模态
184
00:08:28,241 --> 00:08:30,808
presentation style is set in that view controller which by
演讲风格是由设置在视图控制器
185
00:08:30,877 --> 00:08:33,612
default is modal,
默认是模态的,
186
00:08:33,680 --> 00:08:37,915
So the action sheet slides at the bottom and
所以动作表单底部幻灯片
187
00:08:37,984 --> 00:08:41,386
it's being modally presented,
它是模式地展现,
188
00:08:43,657 --> 00:08:45,623
So that looks good on the iPhone but
这在iPhone上看起来不错,但
189
00:08:45,692 --> 00:08:47,058
what about on the iPad,
在iPad上呢,
190
00:08:47,127 --> 00:08:49,627
It would look terrible if that huge, if the thing was
它看起来可怕如果很大,如果是
191
00:08:49,696 --> 00:08:51,896
all the way the width of the iPad and came up,
所有的iPad和出来的宽度,
192
00:08:51,965 --> 00:08:54,498
Or if it was just tiny even in the middle it was just look
或者这只是小中间甚至只是看
193
00:08:54,567 --> 00:08:55,533
out of place right there,
不合适的,
194
00:08:55,601 --> 00:09:00,605
So of course on an iPad we put this action sheet in a pop
所以当然在iPad上我们把这个动作表单流行
195
00:09:00,674 --> 00:09:02,207
And whatever button causes us to have to do this branching
不管按钮使我们必须这样去做分支
196
00:09:02,208 --> 00:09:03,741
over,
结束了,
197
00:09:03,810 --> 00:09:06,677
decision, that's the button that we're gonna have
的决定,这是我们要的按钮
198
00:09:06,746 --> 00:09:08,213
the little arrow point to,
小箭头指向,
199
00:09:08,282 --> 00:09:10,782
So how do we make that work?
那么,我们如何让工作吗?
200
00:09:10,850 --> 00:09:12,650
we're presenting this alert using the modal style,
我们提出这个警报使用模态风格,
201
00:09:12,651 --> 00:09:14,451