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学习手册
用户界面和
iCloud
159
3.
接下来,在
Xcode
或你喜欢的文本编辑器中新建一个文本文件,将其命名为
Location.json
,然后写入下述文本:
{
"lat": -42.882743,
"long": 147.330234
}
4.
把这个
JSON
文件添加到文档中,然后双击。它会在地图应用中打开(见图
6-23
)。
6-23
Notes 应用和 OS X 自带的地图应用
显示着作者办公室的位置
14
章为
iOS
应用添加位置附件时会进一步说明如何处理位置。
6.4
通过拖曳添加附件
接下来,我们将支持拖曳添加附件的功能。
为了在视图中支持拖曳,我们要实现特定的方法,定义哪些内容可以拖曳视图,例如
URL
、颜色和文本。集合视图特殊一些,支持委托给其他对象,我们就使用这种方式。
我们要注册附件列表,让它支持拖曳。最好在
windowControllerDidLoadNib
方法中注册,
这个方法在界面加载之后、出现在屏幕上之前调用。
windowControllerDidLoadNib
方法
准备用户能看到的所有视图,以便显示出来,因此这是设置用户界面行为的最早机会。
windowControllerDidLoadNib
方法执行完毕后,绑定系统接手,从
Document
对象中获取
信息,然后把数据显示在窗口里的视图中。
160
6
1.
更新
Document
类中的
windowControllerDidLoadNib
方法:
override func windowControllerDidLoadNib(windowController: ...
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