Chapter 8. Viewing and Editing Selfies
So far all the work we’ve done has been centered around the list of selfies, which makes sense because it is the jumping-off point for Selfiegram—but now it’s time to add the ability to look at past selfies. After all, there isn’t any point in taking all those selfies if we can’t later look at how great they are! We’ll also add the ability to edit the selfie titles, so they don’t all have the same boring label.
The Selfie Viewer
Let’s get started on creating our selfie viewer:
-
Open Main.storyboard and select the selfie detail view controller.
-
Delete the template text label in the middle of the main view.
-
Drag in a
UITextField
and place it near the top left of the main view. -
Use the Add New Constraints menu to position the text field as follows:
- 16 points away from the left edge of the view
- 16 points away from the right edge of the view
- 16 points away from the top edge of the navigation bar
- Height: 30 points
-
Inside the Attributes inspector, set the placeholder of the text field to “Selfie Name”.
-
Set the border style to be None (the dotted line option in the list).
This is the first part of our selfie viewer. We are using a text field because later we are going to make it so users can rename selfies from here. The constraints we’ve set up on it ensure that no matter how large or small the device may be it will always be pinned to the top of the view, stretching across the width of the device.
-
Drag in a
UILabel
and place it ...
Get Learning Swift, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.