Nothing Special   »   [go: up one dir, main page]

Beginning Xamarin Development For

Download as pdf or txt
Download as pdf or txt
You are on page 1of 53

Full download test bank at ebook textbookfull.

com

Beginning Xamarin Development for


the Mac: Create iOS, watchOS, and
Apple tvOS apps with Xamarin.iOS
and Visual Studio for Mac 1st
CLICK LINK TO DOWLOAD

https://textbookfull.com/product/beginning-
xamarin-development-for-the-mac-create-ios-
watchos-and-apple-tvos-apps-with-xamarin-ios-
and-visual-studio-for-mac-1st-edition-dawid-
borycki/

textbookfull
More products digital (pdf, epub, mobi) instant
download maybe you interests ...

Beginning Visual Studio for Mac: Build Cross-Platform


Apps with Xamarin and .NET Core Alessandro Del Sole

https://textbookfull.com/product/beginning-visual-studio-for-mac-
build-cross-platform-apps-with-xamarin-and-net-core-alessandro-
del-sole/

Biota Grow 2C gather 2C cook Loucas

https://textbookfull.com/product/biota-grow-2c-gather-2c-cook-
loucas/

Build, Run, and Sell Your Apple Consulting Practice:


Business and Marketing for iOS and Mac Start Ups
Charles Edge

https://textbookfull.com/product/build-run-and-sell-your-apple-
consulting-practice-business-and-marketing-for-ios-and-mac-start-
ups-charles-edge/

Beginning iOS AR Game Development: Developing Augmented


Reality Apps with Unity and C# 1st Edition Allan Fowler

https://textbookfull.com/product/beginning-ios-ar-game-
development-developing-augmented-reality-apps-with-unity-
and-c-1st-edition-allan-fowler/
Visual Studio Extensibility Development: Extending
Visual Studio IDE for Productivity, Quality, Tooling,
and Analysis Rishabh Verma

https://textbookfull.com/product/visual-studio-extensibility-
development-extending-visual-studio-ide-for-productivity-quality-
tooling-and-analysis-rishabh-verma/

Machine Learning by Tutorials Beginning Machine


Learning for Apple and iOS First Edition Raywenderlich
Tutorial Team

https://textbookfull.com/product/machine-learning-by-tutorials-
beginning-machine-learning-for-apple-and-ios-first-edition-
raywenderlich-tutorial-team/

Beginning Ubuntu for Windows and Mac Users : Start your


Journey into Free and Open Source Software Haines

https://textbookfull.com/product/beginning-ubuntu-for-windows-
and-mac-users-start-your-journey-into-free-and-open-source-
software-haines/

Beginning Ubuntu for Windows and Mac Users: Start your


Journey into Free and Open Source Software Nathan
Haines

https://textbookfull.com/product/beginning-ubuntu-for-windows-
and-mac-users-start-your-journey-into-free-and-open-source-
software-nathan-haines/

Beginning Ubuntu for Windows and MAC users: start your


journey into free and open source software Second
Edition Haines

https://textbookfull.com/product/beginning-ubuntu-for-windows-
and-mac-users-start-your-journey-into-free-and-open-source-
software-second-edition-haines/
Beginning Xamarin
Development for
the Mac
Create iOS, watchOS, and Apple tvOS apps
with Xamarin.iOS and Visual Studio for Mac

Dawid Borycki
Beginning Xamarin
Development for
the Mac
Create iOS, watchOS, and Apple tvOS apps
with Xamarin.iOS and Visual Studio for Mac

Dawid Borycki
Beginning Xamarin Development for the Mac
Dawid Borycki
Institute of Physical Chemistry,
Polish Academy of Sciences,
Kasprzaka 44/52, Warsaw, 01-224, Poland
ISBN-13 (pbk): 978-1-4842-3131-9 ISBN-13 (electronic): 978-1-4842-3132-6
https://doi.org/10.1007/978-1-4842-3132-6
Library of Congress Control Number: 2017963095
Copyright © 2018 by Dawid Borycki
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are
not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Cover image designed by Freepik
Managing Director: Welmoed Spahr
Editorial Director: Todd Green
Acquisitions Editor: Joan Murray
Development Editor: Laura Berendson
Technical Reviewer: Chaim Krause
Coordinating Editor: Jill Balzano
Copy Editor: April Rondeau
Compositor: SPi Global
Indexer: SPi Global
Artist: SPi Global
Distributed to the book trade worldwide by Springer Science+Business Media New York,
233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505,
e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California
LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc).
SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail rights@apress.com, or visit http://www.apress.com/
rights-permissions.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions
and licenses are also available for most titles. For more information, reference our Print and eBook Bulk
Sales web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub via the book’s product page, located at www.apress.com/9781484231319. For more
detailed information, please visit http://www.apress.com/source-code.
Printed on acid-free paper
This book is dedicated to my wife, Agnieszka, daughter, Susanna, and son, Xavier, with love.
We all have dreams. But in order to make dreams come into reality, it takes an awful
lot of determination, dedication, self-discipline, and effort.

—Jesse Owens
Contents

About the Author����������������������������������������������������������������������������������������������������� ix


About the Technical Reviewer��������������������������������������������������������������������������������� xi
Acknowledgments������������������������������������������������������������������������������������������������� xiii
Introduction�������������������������������������������������������������������������������������������������������������xv


■Chapter 1: Fundamentals�������������������������������������������������������������������������������������� 1
Setting Up the Development Environment����������������������������������������������������������������������� 2
Hello, World! App�������������������������������������������������������������������������������������������������������������� 8
Creating the Project�������������������������������������������������������������������������������������������������������������������������������� 8
Storyboard Designer����������������������������������������������������������������������������������������������������������������������������� 16
User Interface��������������������������������������������������������������������������������������������������������������������������������������� 17
AlertViewController������������������������������������������������������������������������������������������������������������������������������� 20
Actions�������������������������������������������������������������������������������������������������������������������������������������������������� 23
Action Sheet����������������������������������������������������������������������������������������������������������������������������������������� 25

Summary ����������������������������������������������������������������������������������������������������������������������� 26

■Chapter 2: App Structure and Lifecycle��������������������������������������������������������������� 27
An Entry Point����������������������������������������������������������������������������������������������������������������� 27
AppDelegate������������������������������������������������������������������������������������������������������������������� 29
View Lifecycle���������������������������������������������������������������������������������������������������������������� 32
Information Property List������������������������������������������������������������������������������������������������ 34
Entitlements Property List���������������������������������������������������������������������������������������������� 35
Launch Storyboard �������������������������������������������������������������������������������������������������������� 36
Storyboards Under the Hood������������������������������������������������������������������������������������������ 38
Model View Controller���������������������������������������������������������������������������������������������������� 41
v
■ Contents

Persisting Data��������������������������������������������������������������������������������������������������������������� 42
Summary������������������������������������������������������������������������������������������������������������������������ 46

■Chapter 3: Views������������������������������������������������������������������������������������������������� 47
Basic Controls���������������������������������������������������������������������������������������������������������������� 47
Tables����������������������������������������������������������������������������������������������������������������������������� 50
Displaying Items����������������������������������������������������������������������������������������������������������������������������������� 51
Selecting Items������������������������������������������������������������������������������������������������������������������������������������� 55
Deleting Items�������������������������������������������������������������������������������������������������������������������������������������� 57

Web View������������������������������������������������������������������������������������������������������������������������ 61
Google Geocoding API��������������������������������������������������������������������������������������������������������������������������� 64
Invoking JavaScript Functions�������������������������������������������������������������������������������������������������������������� 66

Map View and Geolocation��������������������������������������������������������������������������������������������� 68


Auto-Layout�������������������������������������������������������������������������������������������������������������������� 73
Size Classes������������������������������������������������������������������������������������������������������������������� 77
UI Thread������������������������������������������������������������������������������������������������������������������������ 80
Summary������������������������������������������������������������������������������������������������������������������������ 82

■Chapter 4: Navigation������������������������������������������������������������������������������������������ 83
Tab Bar��������������������������������������������������������������������������������������������������������������������������� 83
Pages���������������������������������������������������������������������������������������������������������������������������������������������������� 90
Navigation Between View Controllers��������������������������������������������������������������������������������������������������� 95
Editing a Segue������������������������������������������������������������������������������������������������������������������������������������� 97
Unwind Segue�������������������������������������������������������������������������������������������������������������������������������������� 98
Preparing for Segues���������������������������������������������������������������������������������������������������������������������������� 99

Summary���������������������������������������������������������������������������������������������������������������������� 100

■Chapter 5: Touch������������������������������������������������������������������������������������������������ 101
Touches and Gesture Recognizers������������������������������������������������������������������������������� 101
Swipe and Long-Press Gesture Recognizers��������������������������������������������������������������� 103
Manipulating Controls with Gestures��������������������������������������������������������������������������� 107

vi
■ Contents

Pan Gesture Recognizer��������������������������������������������������������������������������������������������������������������������� 107


Detecting Gesture Location���������������������������������������������������������������������������������������������������������������� 109
Rotation and Pinch Gesture Recognizers�������������������������������������������������������������������������������������������� 111

Summary���������������������������������������������������������������������������������������������������������������������� 116

■Chapter 6: Unit Testing�������������������������������������������������������������������������������������� 117
Creating a Model to Test����������������������������������������������������������������������������������������������� 119
Implementing Unit Tests����������������������������������������������������������������������������������������������� 120
Running Unit Tests�������������������������������������������������������������������������������������������������������� 126
User Interface Tests������������������������������������������������������������������������������������������������������ 127
Creating an App���������������������������������������������������������������������������������������������������������������������������������� 128
Xamarin Test Cloud Agent������������������������������������������������������������������������������������������������������������������� 128
Creating UI Tests��������������������������������������������������������������������������������������������������������������������������������� 130

Xamarin Test Cloud������������������������������������������������������������������������������������������������������� 135


Provisioning Profile����������������������������������������������������������������������������������������������������������������������������� 136
Running Tests in the XTC�������������������������������������������������������������������������������������������������������������������� 140

Summary���������������������������������������������������������������������������������������������������������������������� 142

■Chapter 7: Consuming RESTful Web Services���������������������������������������������������� 143
REST Service Client������������������������������������������������������������������������������������������������������ 145
Updating Data������������������������������������������������������������������������������������������������������������������������������������� 148
Getting a Specific User����������������������������������������������������������������������������������������������������������������������� 149
Testing the REST Client������������������������������������������������������������������������������������������������ 149
Users Repository���������������������������������������������������������������������������������������������������������� 152
Presenting a List of Users�������������������������������������������������������������������������������������������� 155
Displaying User Details������������������������������������������������������������������������������������������������ 158
Summary���������������������������������������������������������������������������������������������������������������������� 162

■Chapter 8: watchOS������������������������������������������������������������������������������������������� 163
Creating the Project������������������������������������������������������������������������������������������������������ 163
Watch App Bundle�������������������������������������������������������������������������������������������������������� 165
Watch Extension����������������������������������������������������������������������������������������������������������� 166

vii
■ Contents

Hello, Watch!���������������������������������������������������������������������������������������������������������������� 166


Watch Simulator����������������������������������������������������������������������������������������������������������� 169
View Lifecycle�������������������������������������������������������������������������������������������������������������� 171
App Lifecycle���������������������������������������������������������������������������������������������������������������� 173
Text Input���������������������������������������������������������������������������������������������������������������������� 175
Force Touch and Navigation����������������������������������������������������������������������������������������� 177
Notification Controller�������������������������������������������������������������������������������������������������� 181
ClockKit and Complication Controller��������������������������������������������������������������������������� 184
Glance Controller���������������������������������������������������������������������������������������������������������� 189
Summary���������������������������������������������������������������������������������������������������������������������� 191

■Chapter 9: tvOS�������������������������������������������������������������������������������������������������� 193
Creating a Project��������������������������������������������������������������������������������������������������������� 194
User Interface��������������������������������������������������������������������������������������������������������������� 195
OpenWeatherMap API��������������������������������������������������������������������������������������������������� 197
Retrieving the Weather Report������������������������������������������������������������������������������������� 199
Presenting the Weather������������������������������������������������������������������������������������������������ 202
Temperature Units�������������������������������������������������������������������������������������������������������� 205
Testing the App in a Simulator������������������������������������������������������������������������������������� 206
Summary���������������������������������������������������������������������������������������������������������������������� 209

Index��������������������������������������������������������������������������������������������������������������������� 211

viii
About the Author

Dawid Borycki is a software engineer, biomedical researcher, and an


expert in several Microsoft developer technologies. He has resolved a
broad range of software development challenges for device prototypes
(mainly medical equipment), embedded device interfacing, and desktop
and mobile programming. Dawid regularly speaks at international
developers conferences and has published, cited, and presented on
numerous developer topics, including web technologies, mobile/cross-
platform development, wearables, embedded, and more.

ix
About the Technical Reviewer

Chaim Krause is an expert computer programmer with over thirty years


of experience to prove it. He worked as a lead tech support engineer for
ISPs as early as 1995 and as a senior developer support engineer with
Borland for Delphi, and has worked in Silicon Valley for over a decade
in various roles, including technical support engineer and developer
support engineer. He is currently a military simulation specialist for the
US Army’s Command and General Staff College, working on projects such
as developing serious games for use in training exercises. He has also
authored several video training courses on Linux topics and has been
a technical reviewer for over twenty books, including iOS Code Testing,
Android Apps for Absolute Beginners (4th ed.), and XML Essentials for C#
and .NET Development (all Apress). It seems only natural then that he
would be an avid gamer and have his own electronics lab and server room in his basement. He currently
resides in Leavenworth, Kansas, with his loving partner, Ivana, and a menagerie of four-legged companions:
their two dogs, Dasher and Minnie, and their three cats, Pudems, Talyn, and Alaska.

xi
Acknowledgments

Dear reader, you hold or view this book thanks to Joan Murray, who was very encouraging of my book
proposal and provided a lot of writing tips.
I am grateful to Chaim Krause for providing a very detailed technical review and catching even the
smallest mistakes.
Many thanks go to Laura Berendson for reading the manuscript, providing feedback, and giving general
advice. I thank Jill Balzano for her patience and keeping track of the book project. I also thank Welmoed
Spahr and Todd Green for publishing this book and April Rondeau for copyediting.
Finally, special thanks go to my wife, Agnieszka, daughter, Susanna, and son, Xavier, for their
continuous support and patience shown to me during the writing of this book.

xiii
Introduction

The programming of mobile apps has recently become one of the most important and exciting aspects of
the IT market, leading to numerous applications. At the same time, mobile development is very challenging
because of market fragmentation, which is manifested by the presence of devices of different sizes, operating
systems, and software development tools. So, to start doing mobile development, you need to take into
account these various factors and decide your strategy.
There are three leading mobile platforms: Apple (including iOS, watchOS, and tvOS), Android, and
Universal Windows Platform (UWP), each of which provides dedicated tools for developing apps. Each
platform has specific hardware requirements. Clearly, iOS SDKs require you to use the local Mac machine
or the remote build agent installed on a Mac. UWP apps can be built on Windows 10 machines. Finally, you
can use either Mac or Windows machines to develop Android apps. So, first and foremost, the question to
answer is that of which hardware to choose. For mobile development, the Intel-based Mac platform is the
best choice because it allows you to use macOS and Windows 10 concurrently. The latter can be installed
natively through the Boot Camp or virtually using the Parallels Desktop. Accordingly, Mac machines will give
you the most flexibility.
After choosing the hardware, you need to select the software development strategy. You have three
traditional options here:
• Native apps – In this case, you use platform SDKs, which require you to utilize
platform-specific IDEs and programming languages. For instance, in terms of iOS,
watchOS, and tvOS, you would need to use either Swift or Objective-C along with
Xcode. Native tools give you full access to the platform API at the cost of needing to
learn platform-specific programming languages.
• Hybrid apps – They are programmed with web technologies as web pages. These
pages are then rendered with a native WebView component, which can be virtually
understood as the local web browser, delivered by each platform. In this case, you
have a lot of flexibility in terms of programming tools and can use the same code
across various platforms at the cost of reduced access to platform-specific APIs.
• Mobile web apps – They are web apps whose views are tailored to mobile
devices. Such a strategy is the simplest to apply but does not let you access device
components, and it also requires a network connection.
Of course, development strategy is dictated by a number of factors, ranging from your programming
preferences to application complexity and target platforms. If you intend to target multiple platforms at
the same time, you can choose one of the cross-platform mobile tools, like Xamarin.Forms, Qt Mobile,
Embarcadero RAD Studio, or React Native. They provide an additional layer of the unified, platform-
independent programming API, which is translated to a platform-specific API during compilation.
Importantly, cross-platform instruments provide not only access to the API but also to visual controls. For
instance, if you create a message dialog, it will be converted during compilation to the platform-specific
message dialog. As a result, in such a “Write once, run anywhere (WORA)” approach, you can indeed
compile the same code across various platforms at the cost of flexibility. Finally, if your goal is to extensively
utilize platform-specific APIs, you will choose Xamarin.iOS or Xamarin.Android. These let you develop

xv
■ Introduction

native apps with C# or F#. Xamarin.iOS and Xamarin.Android provide an additional thin layer that maps C#
or F# code onto the native platform API. You typically use Xamarin.iOS and Xamarin.Android to implement
logic and design the UI separately for each platform. Although you have the extra work of creating platform-
specific UIs, you can still share the platform-independent code between various apps. Such an approach
gives you two important advantages:
• Your app is native. So, it looks like any other built-in app, as it utilizes native visual
controls.
• Your app is written in modern programming language. As a result, you have easy
access to numerous libraries and a wide community. This is especially important
when you are C# programmer who wants to start developing mobile apps.
In this book, we will learn how to use Xamarin.iOS to develop apps for Apple devices: iPhone and iPad
(iOS), Apple Watch (watchOS), and Apple TV (tvOS). We will first prepare the development tools (Visual Studio
for Mac) and will get to know available project templates (Chapter 1). Subsequently, I will explicitly show how
Xamarin.iOS is related to the native SDKs delivered by Apple, and we will investigate the app structure and
lifecycle (Chapter 2). Then, we will learn how to create views (Chapter 3) and implement navigation between
them (Chapter 4). Afterward, we will work with touch gestures (Chapter 5), study how to achieve high-quality
apps with automatic testing (Chapter 6), and consume data from RESTful web services (Chapter 7). Finally,
we will learn how to develop apps for Apple Watches (Chapter 8) and Apple TVs (Chapter 9).
In this book, however, we will not learn how to reuse code between various platforms nor how to
develop WORA apps with Xamarin.Forms. You can find more information about this in this book Beginning
Visual Studio for Mac: Build Cross-Platform Apps with Xamarin and .NET Core by Alessandro Del Sole.

xvi
CHAPTER 1

Fundamentals

In this chapter, I will guide you through the installation of the development tools you will need for this book.
Specifically, we will install Visual Studio for Mac as well as Xcode. The latter is the native toolset for Mac
developers. It delivers IDE, SDKs, and also the device simulators we will use. If you have these tools already
installed, you can skip to the subsequent section.
After ensuring that all tools are ready, we will create the first Xamarin.iOS app for the iPhone and iPad.
This app, shown in Figure 1-1, displays various alerts and responds to user actions. I will also discuss the
available project templates that are delivered by Visual Studio. The same templates are available in Xcode, so
Xamarin.iOS and Visual Studio let you access iOS platform–specific programming interfaces in a way similar
to native development tools but with the ease and smoothness provided by the C# programming language.
In this chapter, I will also discuss the basic aspects of designing user interfaces in Visual Studio and show
you how to associate event handlers with events fired by visual controls.

■■Note In this chapter, I will not discuss Visual Studio for Mac in detail. I will only discuss the necessary
elements of this IDE. You can find a comprehensive description of Visual Studio for Mac in the book Beginning
Visual Studio for Mac. Build Cross-Platform Apps with Xamarin and .NET Core by Alessandro Del Sole.

© Dawid Borycki 2018 1


D. Borycki, Beginning Xamarin Development for the Mac, https://doi.org/10.1007/978-1-4842-3132-6_1
Chapter 1 ■ Fundamentals

Figure 1-1. The Hello, World! app we will build in this chapter. The app is executed in the iPhone X simulator.

Setting Up the Development Environment


To install Visual Studio for Mac, you’ll need a Mac with macOS Sierra 10.12 or above. Here, I’ll be using either
a MacBook Pro or iMac with macOS Sierra 10.16. Once you know that you meet basic platform requirements,
you can download the Visual Studio installer from the following website: http://bit.ly/vs-mac. Once you
have downloaded the installation package, run the installer. A window appears, as shown in Figure 1-2. In this
window, you double-click the icon with a down arrow. Subsequently, you will see a dialog informing you that
the installer was downloaded from the internet (Figure 1-3). Click the Open button to continue.

2
Chapter 1 ■ Fundamentals

Figure 1-2. An installer for Visual Studio for Mac

Figure 1-3. A confirmation dialog

Visual Studio installer will now verify your system configuration (Figure 1-4). More specifically, it looks
for installed components (like Mono Framework, Java SDK, and so on) in order to verify which of them have
to be downloaded and installed. Once this is done, another dialog appears on top of the window shown in
Figure 1-4. Its header tells you “Thank you for downloading Visual Studio.” In this dialog, you simply press
the Continue button.

3
Chapter 1 ■ Fundamentals

Figure 1-4. Visual Studio installer is inspecting the operating system

At this point, the Visual Studio installer might prompt you to install Xcode (Figure 1-5). This happens
only if you do not have Xcode already installed. According to this dialog, you can install Xcode concurrently
with the Visual Studio installation. Note that the Xcode installation is optional and depends on your current
system configuration. I assume that you start with a clean install of macOS and therefore explicitly show how
to install Xcode.

4
Chapter 1 ■ Fundamentals

Figure 1-5. A dialog prompting for Xcode installation

To install Xcode, you can press the Get Xcode button shown in Figure 1-5. This will direct you to a
website, where you click the View in Mac App Store or Install App button. It opens the Xcode page in the
App Store, on which you only need to click the Install App button (Figure 1-6). Alternatively, to install Xcode
you can open the Mac App Store locally and then look up Xcode. Irrespective of which method you choose,
Xcode and all related developer tools will be downloaded and installed in the background. So, you can now
go back to Visual Studio installer.

5
Chapter 1 ■ Fundamentals

Figure 1-6. Xcode page in the Mac App Store

The Visual Studio installer will now let you choose which components to install (Figure 1-7). To reduce
installation size, I uncheck the “Android + Xamarin.Forms” entry and only install iOS- and macOS-related
components. Then, after you click the Install button, the actual installation process begins.

6
Chapter 1 ■ Fundamentals

Figure 1-7. Choosing components to install

Visual Studio will now download and install the components. This will take a while, depending on
network speed. You will be informed about each installation step and the overall progress, as shown in
Figure 1-8. Also, as depicted in this figure, macOS may prompt you for the administrator password several
times during installation. Once installation has finished, an appropriate dialog appears. Note that to build
and run apps in the simulator, you will need to wait until Xcode installation has finished.

7
Chapter 1 ■ Fundamentals

Figure 1-8. Installing Visual Studio for Mac

Hello, World! App


After installing the development tools, we can start building the first app. To jumpstart the Xamarin.iOS
development, I will tell you how to create the project using the Single View app template. Then, we will
supplement the app with a single button. This button will react to taps such that the native alert will be
displayed. Subsequently, we will add specific actions to this alert. Displaying alerts is a typical functionality
of not only introductory apps, but also real apps, where it is used to collect user input or get confirmation for
performing irreversible operations.

Creating the Project


To create the project, open Visual Studio for Mac. A welcome screen, depicted in Figure 1-9, appears. Then,
you either choose File/New Solution in the menu bar or click the New Project button, located under the
“Recent” header. This activates the New Project window, shown in Figure 1-10.

8
Chapter 1 ■ Fundamentals

Figure 1-9. A welcome screen for Visual Studio for Mac

9
Chapter 1 ■ Fundamentals

Figure 1-10. Project template selection

The New Project creator lets you choose a template for your project. To filter the list of templates to
items directly related to iOS apps, you click App entry under the iOS tab. A list of available project templates
will then appear on the right. This list is divided into two categories: General and Games. In this book, we
will only use project templates from the General group. This category contains the following templates:
• Single View App — You use this template to create the app, which comprises a single
view; i.e., an app without any navigation, like the app shown in Figure 1-1.
• Master-Detail App — This template creates apps that use Master-Detail interface. In
such cases, a list displays short descriptions of objects. Once you choose an object from
this list (master), corresponding details will be displayed in the dedicated area (detail).
Master-Detail interface is used, for example, in the Stocks iOS app (Figure 1-11).

10
Chapter 1 ■ Fundamentals

Figure 1-11. Representational view of a Master-Detail iOS app. The list of objects (companies) is shown on
top. When you tap any of these objects, corresponding details (stock values) appear at the bottom.

• Tabbed App — You use this template to create a multi-tab application in which you
can arrange visual controls in multiple tabs. User then navigates between tabs using
labeled icons shown at the botton of the screen. Such navigation is used in the Clock
iOS app (Figure 1-12).

11
Chapter 1 ■ Fundamentals

Figure 1-12. An example of Tabbed iOS application. You switch between tabs using labeled icons displayed in
the bottom part of the view

• Page-based App — Use this template to create a multi-view app in which controls are
arranged in pages. The user swipes between pages with touch gestures. For instance,
such page-based navigation is utilized in the Weather iOS app, shown in Figure 1-13.

12
Chapter 1 ■ Fundamentals

Figure 1-13. Page-based navigation is utilized in the Weather app to switch between weather forecasts

• WebView App — You use this template to jumpstart hybrid app development. This
project template creates a view with an embedded WebView control. The latter
renders a website written with HTML, CSS, and JavaScript. I will tell you more about
WebView in Chapter 3.
To proceed further, let’s pick the Single View app project template and keep the default language
selection of C#. Then, you will have the option to specify the name of your app and organization identifier
(Figure 1-14). I set these values to HelloWorld and com.db, respectively. The next group of controls in app
configuration lets you specify which devices will be supported by your app. In this case, I made my app
universal and chose iPad and iPhone. The very last control in the app configuration screen is the Target
drop-down list. You use this list to select the minimum iOS version that will be supported by your app. I
set this to iOS 9.0. After configuring the app, press the Next button, which activates the view depicted in
Figure 1-15.

13
Chapter 1 ■ Fundamentals

Figure 1-14. iOS app configuration

The Project Summary window shown in Figure 1-15 displays the project and solution names. You can
also use this screen to set the location for your source code, enable version control, and add an automated
UI test project. Here, I keep the settings at their default values. I will tell you more about unit testing in
Chapter 6. So, go ahead and press the Create button to proceed further. You will quickly see the Getting
Started screen of Visual Studio (Figure 1-16).

14
Chapter 1 ■ Fundamentals

Figure 1-15. Project summary

The Getting Started screen displays several options for you. Specifically, it lets you start designing
the user interface (UI) of your app, add a mobile backend, and unit test the project. Also, on the left-hand
side of this window you will see the Solution Explorer, which displays the structure of the HelloWorld app.
Specifically, there is a HelloWorld solution, under which you can find the project of the same name (refer to
Figure 1-15). This project contains the files that make up your app. They are discussed in more detail in the
next chapter. For now, let’s create a simple UI for the HelloWorld app using the Storyboard (or iOS) Designer.

15
Chapter 1 ■ Fundamentals

Figure 1-16. HelloWorld project open in Visual Studio

Storyboard Designer
To start creating the UI, you can click the Open Storyboard Designer button. This will open the Main.
storyboard file and activate the Visual Interface or Storyboard Designer (or simply iOS Designer) of Visual
Studio. This designer is shown in Figure 1-17. Three elements of this designer should be discussed in more
detail, as follows:
• Visual preview of the app. This element covers the central part of the designer
and lets you see how your views will be displayed in the device without your
having to run your app. For multi-view apps, the visual preview will also depict the
relationships between views (tabs or pages) through which the user can navigate.
• Toolbox, which is in the top-right corner, contains a list of visual objects you can drag
on the view.
• Properties window, located below the Toolbox. You use the Properties window to
change the appearance of and configure visual controls, to define the layout, and to
wire methods to events (like tap or input) fired by controls.
Note that you can also activate the preceding windows or pads using an appropriate menu option in
Visual Studio: View ➤ Pads (see Figure 1-18). There is also one useful drop-down list in the preview mode.
That is the View As list, which you can find on the top pane of the visual preview. The View As drop-down list
lets you choose the device type to use for the preview. As shown in Figure 1-17, I set this device to iPhone 6.

16
Another random document with
no related content on Scribd:
The Project Gutenberg eBook of Pausanias'
description of Greece, Volume II
This ebook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this ebook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

Title: Pausanias' description of Greece, Volume II

Author: active approximately 150-175 Pausanias

Translator: A. R. Shilleto

Release date: August 4, 2022 [eBook #68680]

Language: English

Original publication: United Kingdom: George Bell and Sons,


1886

Credits: Turgut Dincer, SF2001, and the Online Distributed


Proofreading Team at https://www.pgdp.net (This book
was produced from images made available by the
HathiTrust Digital Library.)

*** START OF THE PROJECT GUTENBERG EBOOK PAUSANIAS'


DESCRIPTION OF GREECE, VOLUME II ***
BOHN’S CLASSICAL LIBRARY.

PAUSANIAS’ DESCRIPTION OF
GREECE.
PAUSANIAS’
DESCRIPTION OF GREECE,
TRANSLATED INTO ENGLISH

WITH NOTES AND INDEX

BY ARTHUR RICHARD SHILLETO, M.A.,


Sometime Scholar of Trinity College, Cambridge.

VOLUME II.

“Pausanias est un homme qui ne manque ni de bon sens ni de


bonne foi, mais qui croit ou au moins voudrait croire à ses dieux.” —
Champagny.

LONDON: GEORGE BELL AND SONS,


YORK STREET, COVENT GARDEN.
1886.
CHISWICK PRESS:—C. WHITTINGHAM AND CO., TOOKS
COURT, CHANCERY LANE.
CONTENTS.
page
Book VII. Achaia 1
VIII. Arcadia 61
IX. Bœotia 151
X. Phocis 219
index 299
ERRATA.
Volume Page 8, line 37, for “Atte” read “Attes.” As vii. 17, 20.
I. (Catullus’ Attis.)
Page 150, line 22, for “Auxesias” read “Auxesia.” As ii. 32.
Page 165, lines 12, 17, 24, for “Philhammon” read
“Philammon.”
Page 191, line 4, for “Tamagra” read “Tanagra.”
Page 215, line 35, for “Ye now enter” read “Enter ye now.”
Page 227, line 5, for “the Little Iliad” read “The Little Iliad.”
Page 289, line 18, for “the Babylonians” read “Babylon.”
Volume
Page 61, last line, for “earth” read “Earth.”
II.
Page 95, line 9, for “Camira” read “Camirus.”
Page 169, line 1, for “and” read “for.”
---- ---- line 2, for “other kinds of flutes” read “other flutes.”
Page 201, line 9, for “Lacenian” read “Laconian.”
Page 264, line 10, for “Chilon” read “Chilo.” As iii. 16.
Page 268, Note, for “I iad” read “Iliad.”
PAUSANIAS.
BOOK VII.—ACHAIA.
CHAPTER I.

N ow the country between Elis and Sicyonia which borders on the


Corinthian Gulf is called in our day Achaia from its inhabitants,
but in ancient times was called Ægialus and its inhabitants
Ægialians, according to the tradition of the Sicyonians from
Ægialeus, who was king of what is now Sicyonia, others say from the
position of the country which is mostly on the sea-shore.[1] After the
death of Hellen his sons chased their brother Xuthus out of Thessaly,
accusing him of having privately helped himself to their father’s
money. And he fled to Athens, and was thought worthy to marry the
daughter of Erechtheus, and he had by her two sons Achæus and
Ion. After the death of Erechtheus he was chosen to decide which of
his sons should be king, and, because he decided in favour of
Cecrops the eldest, the other sons of Erechtheus drove him out of
the country: and he went to Ægialus and there lived and died. And of
his sons Achæus took an army from Ægialus and Athens and
returned to Thessaly, and took possession of the throne of his
ancestors, and Ion, while gathering together an army against the
Ægialians and their king Selinus, received messengers from Selinus
offering him his only child Helice in marriage, and adopting him as
his son and heir. And Ion was very well contented with this, and after
the death of Selinus reigned over the Ægialians, and built Helice
which he called after the name of his wife, and called the inhabitants
of Ægialus Ionians after him. This was not a change of name but an
addition, for they were called the Ionian Ægialians. And the old name
Ægialus long prevailed as the name of the country. And so Homer in
his catalogue of the forces of Agamemnon was pleased to call the
country by its old name,
“Throughout Ægialus and spacious Helice.”[2]
And at that period of the reign of Ion when the Eleusinians were at
war with the Athenians, and the Athenians invited Ion to be
Commander in Chief, death seized him in Attica, and he was buried
at Potamos, a village in Attica. And his descendants reigned after
him till they and their people were dispossessed by the Achæans,
who in their turn were driven out by the Dorians from Lacedæmon
and Argos. The mutual feuds between the Ionians and Achæans I
shall relate when I have first given the reason why, before the return
of the Dorians, the inhabitants of Lacedæmon and Argos only of all
the Peloponnese were called Achæans. Archander and Architeles,
the sons of Achæus, came to Argos from Phthiotis and became the
sons in law of Danaus, Architeles marrying Automate, and Archander
Scæa. And that they were sojourners in Argos is shewn very clearly
by the name Metanastes (stranger) which Archander gave his son.
And it was when the sons of Achæus got powerful in Argos and
Lacedæmon that the name Achæan got attached to the whole
population. Their general name was Achæans, though the Argives
were privately called Danai. And now when they were expelled from
Argos and Lacedæmon by the Dorians, they and their king
Tisamenus the son of Orestes made the Ionians proposals to
become their colonists without war. But the Ionian Court was afraid
that, if they and the Achæans were one people, Tisamenus would be
chosen as king over both nations for his bravery and the lustre of his
race. So the Ionians did not accept the proposals of the Achæans
but went to blows over it, and Tisamenus fell in the battle, and the
Achæans beat the Ionians, and besieged them in Helice to which
they had fled, but afterwards let them go upon conditions. And the
Achæans buried the body of Tisamenus at Helice, but some time
afterwards the Lacedæmonians, in accordance with an oracle from
Delphi, removed the remains to Sparta, and the tomb of Tisamenus
is now where the Lacedæmonians have their banquetings, at the
place called Phiditia. And when the Ionians migrated to Attica the
Athenians and their king, Melanthus the son of Andropompus,
welcomed them as settlers, in gratitude to Ion and his services to the
Athenians as Commander in Chief. But there is a tradition that the
Athenians suspected the Dorians, and feared that they would not
keep their hands off them, and received the Ionians therefore as
settlers rather from their formidable strength than from goodwill to
them.
[1] Ægialus (αἰγιαλός) is Greek for sea-shore. In this last view
compare the names Pomerania, Glamorganshire.
[2] Iliad, ii. 575.
CHAPTER II.

A nd not many years afterwards Medon and Nileus, the eldest


sons of Codrus, quarrelled as to who should be king over the
Athenians, and Nileus said he would not submit to the rule of Medon,
because Medon was lame in one of his feet. But as they decided to
submit the matter to the oracle at Delphi, the Pythian Priestess
assigned the kingdom to Medon. So Nileus and the other sons of
Codrus were sent on a colony, and took with them whatever
Athenians wished, and the Ionians formed the largest part of the
contingent. This was the third expedition that had started from
Greece under different kings and with different peoples. The oldest
expedition was that of Iolaus the Theban, the nephew of Hercules,
who led the Athenians and people of Thespiæ to Sardinia. And, one
generation before the Ionians sailed from Athens, the
Lacedæmonians and Minyæ who had been expelled by the Pelasgi
from Lemnos were led by Theras the Theban, the son of Autesion, to
the island henceforward called Theras after him, but formerly called
Calliste. And now thirdly the sons of Codrus were put at the head of
the Ionians, though they had no connection with them by race, being
as they were Messenians from Pylos as far as Codrus and
Melanthus were concerned, and Athenians only on their mother’s
side. And the following Greeks took part in this expedition of the
Ionians, the Thebans under Philotas, who was a descendant of
Peneleus, and the Minyæ from Orchomenus, who were kinsmen of
the sons of Codrus. All the Phocians also took part in it (except the
people of Delphi), and the Abantes from Eubœa. And to the
Phocians the Athenians Philogenes and Damon, the sons of
Euctemon, gave ships to sail in, and themselves led them to the
colony. And when they had crossed over to Asia Minor, different
detachments went to different maritime towns, but Nileus and his
contingent to Miletus. The Milesians give the following account of
their early history. They say their country was for two generations
called Anactoria, during the reigns of Anax the Autochthon and
Asterius his son, and that, when Miletus put in there with an
expedition of Cretans, then the town and country changed its name
to Miletus from him. And Miletus and the force with him came from
Crete fleeing from Minos the son of Europa. And the Carians, who
had settled earlier in the neighbourhood of Miletus, admitted the
Cretans to a joint share with them. But now when the Ionians
conquered the old inhabitants of Miletus, they slew all the males
except those that ran away from the captured city, and married their
wives and daughters. And the tomb of Nileus is as you approach
Didymi, not far from the gates on the left of the road. And the temple
and oracle of Apollo at Didymi are of earlier date than the migration
of the Ionians: as also is the worship of the Ephesian Artemis. Not
that Pindar in my opinion understood all about the goddess, for he
says that the Amazons who fought against Theseus and Athens built
the temple to her. Those women from Thermodon did indeed
sacrifice to the Ephesian Artemis, as having known her temple of
old, when they fled from Hercules and earlier still from Dionysus, and
sought refuge there: it was not however built by them, but by
Coresus, an Autochthon, and by Ephesus (who was they think the
son of the river Cayster, and gave his name to the city of Ephesus).
And the Leleges (who form part of Caria) and most of the Lydians
inhabited the district. And several people lived near the temple for
the purpose of supplication, and some women of the Amazonian
race. And Androclus the son of Codrus, who was appointed king of
the Ionians that sailed to Ephesus, drove the Leleges and Lydians
who dwelt in the upper part of the city out of the district; but of those
who lived near the temple no apprehensions were entertained, but
they mutually gave and received pledges with the Ionians without
any hostilities. Androclus also took Samos from the Samians, and for
some time the Ephesians were masters of Samos and the adjacent
islands. And after the Samians returned to their own possessions,
Androclus assisted the people of Priene against the Carians and,
though the Greeks were victorious, fell in the battle. And the
Ephesians took up his corpse, and buried it in their own country
where the tomb is shewn to this day, on the way from the temple by
the Olympiæum to the Magnesian gates. The device on the tomb is
a man in full armour.
And the Ionians, when they inhabited Myus and Priene, drove the
Carians out from those cities. Cyaretus the son of Codrus colonized
Myus, and Priene was colonized by Thebans and Ionians mixed
under Philotas, the descendant of Peneleus, and Æpytus the son of
Nileus. So Priene, which had been ravaged by Tabalus the Persian,
and afterwards by Hiero one of its own citizens, at last became an
Ionian city. But the dwellers in Myus left their town in consequence of
the following circumstance. In the neighbourhood of Myus is a small
bay: this was converted into a marsh by the Mæander filling up the
mouth of the bay with mud. And as the water became foul and no
longer sea, mosquitoes in endless quantities bred in the marsh, till
they compelled the poor people of Myus to leave the place. And they
went to Miletus and carried off with them everything they could take
and the statues of the gods: and in my time there was at Myus only a
temple of Dionysus in white marble. A similar disaster fell upon the
Atarnitæ near Pergamum.
CHAPTER III.

T he Colophonians also regard the temple and oracle of Apollo at


Claros as most ancient, for, while the Carians were still in
possession of the country, they say that the first Greeks who came
there were Cretans, a large force powerful both by land and sea
under Rhacius, and the Carians remained still in possession of most
of the country. But when the Argives and Thersander the son of
Polynices took Thebes, several captives, and among others Manto
were taken to Apollo at Delphi, but Tiresias died on the road not far
from Haliartus.[3] And when the god sent them to form a colony they
crossed over into Asia Minor, and when they got to Claros the
Cretans attacked them and took them before Rhacius. And he,
understanding from Manto who they were and their errand, married
Manto and made her companions fellow-settlers with him. And
Mopsus, the son of Rhacius and Manto, drove out all the Carians
altogether. And the Ionians on mutual conditions became fellow-
citizens upon equal terms with the Colophonian Greeks. And the
kingdom over the Ionians was usurped by their leaders
Damasichthon and Promethus the sons of Codrus. And Promethus
afterwards slew his brother Damasichthon and fled to Naxos, and
died there, and his body was taken home and buried by the sons of
Damasichthon: his tomb is at a place called Polytichides. And how
Colophon came to be dispeopled I have previously described in my
account about Lysimachus: its inhabitants were the only colonists at
Ephesus that fought against Lysimachus and the Macedonians. And
the tombs of those from Colophon and Smyrna that fell in the battle
are on the left of the road to Claros.
Lebedus also was dispeopled by Lysimachus simply to add to the
population of Ephesus. It was a place in many respects favoured,
and especially for its very numerous and agreeable warm baths near
the sea. Originally it was inhabited by the Carians, till Andræmon,
the son of Codrus, and the Ionians drove them out. Andræmon’s
tomb is on the left of the road from Colophon, after you have crossed
the river Calaon.
And Teos was colonized by the Minyæ from Orchomenus, who came
with Athamas; he is said to have been a descendant of Athamas the
son of Æolus. Here too the Carians were mixed up with the Greeks.
And the Ionians were conducted to Teos by Apœcus, the great-
great-grandson of Melanthus, who did no harm to either the
Orchomenians or Teians. And not many years afterwards came men
from Attica and Bœotia, the former under Damasus and Naoclus the
sons of Codrus, the latter under the Bœotian Geres, and both these
new-comers were hospitably received by Apœcus and the people of
Teos.
The Erythræi also say that they came originally from Crete with
Erythrus (the son of Rhadamanthys) who was the founder of their
city, and when the Lycians Carians and Pamphylians occupied the
city as well as the Cretans, (the Lycians being kinsfolk of the
Cretans, having originally come from Crete when they fled from
Sarpedon, and the Carians having an ancient friendship with Minos,
and the Pamphylians also having Greek blood in their veins, for after
the capture of Ilium they wandered about with Calchas), when all
those that I have mentioned occupied Erythræ, Cleopus the son of
Codrus gathered together from all the towns in Ionia various people,
whom he formed into a colony at Erythræ.
And the people of Clazomenæ and Phocæa had no cities before the
Ionians came to Asia Minor: but when the Ionians arrived a
detachment of them, not knowing their way about the country, sent
for one Parphorus a Colophonian as their guide, and having built a
city under Mount Ida left it not long after, and returned to Ionia and
built Scyppius in Colophonia. And migrating of their own accord from
Colophonia, they occupied the territory which they now hold, and
built on the mainland the town of Clazomenæ. But afterwards from
fear of the Persians they crossed over into the island opposite. But in
process of time Alexander the son of Philip was destined to convert
Clazomenæ into a peninsula, by connecting the island with the
mainland by an embankment. Most of the inhabitants of Clazomenæ
were not Ionians, but were from Cleonæ and Phlius, and had left
those cities when the Dorians returned to the Peloponnese. And the
people of Phocæa were originally from the country under Mount
Parnassus which is still to our day called Phocis, and crossed over
into Asia Minor with the Athenians Philogenes and Damon. And they
took territory not by war but on an understanding with the people of
Cyme. And as the Ionians would not receive them into the Pan-Ionic
confederacy unless they received kings from the descendants of
Codrus, they accepted from Erythræ and Teos Deœtes and Periclus
and Abartus.
[3] See Book ix. ch. 33.

You might also like