Skip to Content
Swift学习手册
book

Swift学习手册

by Jon Manning, Paris Buttfield-Addison, Tim Nugent
February 2017
Beginner to intermediate
472 pages
9h 53m
Chinese
China Electric Power Press Ltd.
Content preview from Swift学习手册
286
11
最后,还有一点要考虑。目前,这段代码的目的基本上是为了在
iPad
中执行不同的
操作,但是这样说并不准确。之所以要区别对待,是因为在
iPhone
中,弹出框从屏
幕底部滑出,会遮盖其他内容。这是由于手机的屏幕空间极其有限,不能浪费屏幕
四周附近的空间。
iPad
中,这通常不是问题,但是使用分屏视图时情况就变了。在其他应用中,你
可以从屏幕右边滑出,把
Notes
应用呼出,放在一个窄栏中,差不多占屏幕宽度的
三分之一。此时,应用基本上相当于运行在一个高的
iPhone
中。
因为应用的呈现风格可以变化,所以最好问问自己,到底要处理怎样的行为。不要
简单地以为
iPad
使用一种方式,而
iPhone
使用另一种方式。
因此,我们没有判断“是不是在
iPad
中”,而是检查弹出框是哪种呈现方式。如果
.FullScreen
模式,那就要添加“
Done
”按钮。
在内容视图控制器顶部添加导航栏的最简单方式是把视图控制器放在导航控制器中。
在屏幕顶部添加一个
UINavigationBar
可能会占据内容视图控制器的部分空间,但
是这样能确保其他内容不会被盖住。导航控制器会负责调整内容视图控制器的视图
尺寸,留出空间显示导航栏。
所以,我们采用这种方法,把内容视图控制器嵌入一个新导航控制器中。然后,
我们创建一个
UIBarButtonItem
,把它添加到内容视图控制器的
UINavigationItem
中,这会导致按钮出现在右上角。创建这个按钮时,我们把 target设为 self(即
DocumentViewController ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

PyTorch深度学习

PyTorch深度学习

Posts & Telecom Press, Vishnu Subramanian
深入淺出代數

深入淺出代數

Tracey Pilone, Dan Pilone
PHP学习手册

PHP学习手册

David Sklar
C语言核心技术(原书第2版)

C语言核心技术(原书第2版)

Peter Prinz, Tony Crawford

Publisher Resources

ISBN: 9787519803223