Application Development in iOS 7 by 2014

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



Copyright Disclaimer:
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.