This app launches in landscape orientation. I took the screenshot while the animation was in progress, so the letter G was caught between screen refreshes.
The app animates the
property of a
which is a subview of another
The label has white letters and a clear background;
the view has a blue background and nothing else.
We put the audio code in the
because a subclass of
should concentrate on matters such as background color and fonts.
A view should be seen and not heard.
The audio code does not belong in the application delegate either.
The application delegate should concentrate on lifecycle events—startup
We didn’t need to search for the image file in
America using an
But we do need to search for the sound file here using a
because we need the full pathname of the sound file
in order to create the
With the Wind
ViewController.swift. Added the
AVAudioPlayerproperty and initialized it in the
viewDidLoadmethod. Also added the method
supportedInterfaceOrientationsto launch the app in lanscape orientation.
Info.plist: added the “Initial interface orientation” property to launch the app in landscape orientation.
Drag the file
into the Supporting Files folder of the Xcode Project Navigator.
Choose options for adding these files:
Destination: ☑ Copy items if needed.
Add to targets: ☑ Gone
Then open the Supporting Files folder and make sure
is listed there in black.
Can you select it and play it?
To launch in landcape orientation, follow the “create the project” directions in Sine.
The application delegate has an instance variable that is an
Surprisingly, we do not have to add the
to the project.
Turn on the Macintosh sound.
Run the project.
Does the sound stop when you press the simulator’s Home button?
Hardware → Home
Output produced by
bundle.bundlePath = "/Users/myname/Library/Developer/CoreSimulator/Devices/01EBED35-F21B-4B4C-95BC-BFDDDC6264B4/data/Containers/Bundle/Application/DADF37D1-AB36-4C40-B31B-4FD8B023584B/Gone.app" path = "/Users/myname/Library/Developer/CoreSimulator/Devices/01EBED35-F21B-4B4C-95BC-BFDDDC6264B4/data/Containers/Bundle/Application/DADF37D1-AB36-4C40-B31B-4FD8B023584B/Gone.app/gone.mp3" url = "file:///Users/myname/Library/Developer/CoreSimulator/Devices/01EBED35-F21B-4B4C-95BC-BFDDDC6264B4/data/Containers/Bundle/Application/DADF37D1-AB36-4C40-B31B-4FD8B023584B/Gone.app/gone.mp3" player!.numberOfChannels = 2
UILabels (or a single
UITextView; see here) containing the following two lines. Animate the
UILabels from 0.0 to 1.0.