Application Development in iOS 7 by 2014
Author:2014
Language: eng
Format: mobi
Publisher: Packt Publishing
We have defined both our cancelButtonPressed and saveButtonPressed methods here (saveButtonPressed has been intentionally left blank until later in the chapter). In cancelButtonPressed, we simply tell the view controller to dismiss itself and set the animated view controller to YES. Run the application and test this functionality.
Adjusting our storyboard view
Now that we have some of our code implemented, we need to finish arranging our view in Main.storyboard. Previously, we only added the required elements and did not position or size them correctly. Switch to Main.storyboard and scroll down to the AddNewViewController object.
We have three items to position and size here, starting with the two image views. Select the first image view, and in the Utilities pane, select the Size Inspector submenu. Set the width and height to 180 pixels to create a perfect square. Position this image view horizontally in the center of the view and slightly higher than the vertical center of the view. Do not worry about being precise, and feel free to position the image view where you think it looks best!
Repeat this process for the other image view, making it an identical size and in exactly the same position. For this image view, switch to the Attributes Inspector submenu (in the Utilities pane on the right-hand side) and set its image to placeholder_image for placeholderImageView. Using the documents outline, make sure that this image view is positioned below the other image view. We will be using two image views to assist in save validation. When a user selects or takes an image, it will be set to the top image view (the empty one) and cover the placeholder image view beneath it. This allows us to check if the top image view contains an image. If it does not, it means the user has not added an image and that the placeholder is still visible. In this case, we will alert the user to let him/her know that he/she must include a photo.
Last, we need to adjust the settings of our UITextField object that will be used to type in the name of our food entry. Select the text field and reopen the Size Inspector submenu from the Utilities pane. Set the height to 38 pixels and the width to 280 pixels. Position the text field horizontally centered and slightly above the image views.
Select the Attributes Inspector from the Utilities pane and change the following settings:
Alignment: Select the Center icon
Placeholder: Type The Food Name
Border Style: This field should be set to none (the first of the four buttons)
Capitalization: Select Words
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(6541)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6423)
Kotlin in Action by Dmitry Jemerov(5073)
Odoo 15 Development Essentials - Fifth Edition by Daniel Reis & Greg Mader(3384)
Odoo 15 Development Essentials by Daniel Reis(2818)
React Native - Building Mobile Apps with JavaScript by Novick Vladimir(2539)
Learning Angular - Second Edition by Christoffer Noring(2364)
Pride and Prejudice by Jane Austen(2353)
Mobile Forensics Cookbook by Igor Mikhaylov(2025)
Computers For Seniors For Dummies by Nancy C. Muir(2006)
Bulletproof Android: Practical Advice for Building Secure Apps (Developer's Library) by Godfrey Nolan(1877)
Android Development with Kotlin by Marcin Moskala & Igor Wojda(1805)
Building Android UIs with Custom Views by Raimon Ràfols Montané(1797)
1936941139 (N) by Bob Rosenthal(1739)
Building Progressive Web Apps: Bringing the Power of Native to the Browser by Ater Tal(1733)
Hands-On Internet of Things with MQTT by Tim Pulver(1716)
Android App Development by Franceschi Hervé J.;(1715)
Ember.js in Action by Joachim Haagen Skeie(1693)
Hands-On Design Patterns with React Native by Mateusz Grzesiukiewicz(1659)
