Adding Place VC

Start course
Overview
Difficulty
Intermediate
Duration
3h 18m
Students
2
Description

In this course, we're going to build a Foursquare Clone using Parse. Parse provides you with a great tool to work in cloud servers and you will learn the advantages and disadvantages that come with it.

Intended Audience

This course is designed for anyone who wants to:

  • Learn about iOS development and coding
  • Move into a career as an iOS developer
  • Master Swift skills

Prerequisites

To get the most out of this course, you should have some basic knowledge of iOS.

Transcript

Hi, following this lecture, we're going to spend a couple of lectures in order to finish our user interface. We're going to have to add new view controllers so that we will have a complete app. Right now we already have our places view controller and sign up view controller. When a user taps click button over here, the add button over here actually, they will have to come over a new view controller in which they will have to give out the specifications of the place that is going to be created. For example, like a name, and type, an atmosphere, an image. And if you want anything else to save on the PAR server, you can add this as well.

And then we're going to have a map view controller in which we will choose the coordinates. So, let me bring in the new view controller. We're going to add the new place here. We're going to start with getting the name of the place, the type of the place. So, we're going to need a lot of text fields. So, let me search for one. So, this one, bring in one text field. We can make this a little bit bigger so that it will look better. This one will be the place name. I will make this centrally aligned. Let me zoom in. And here you go. I believe that looks good. So, let me try to copy and paste this, because we're going to need another one. I'm going to call this place type. So, this will be something like either this is a restaurant or a bar or a cafe. And for the third one, I'm going to go for a place atmosphere or description.

So, you can just try to choose your own parameters as well, something like an informative text. I'm going to go for a place atmosphere, something like this is a fancy restaurant, or this is a student cafe or this is fine dining. You are more than welcome to choose your own parameters. I'm going to go for name, type, and place atmosphere so that we will have three options to save into the PARs. And after that, I'm going to need an image view to choose the image of that restaurant or that cafe.

So, this is basic. I'm going to come over here and choose the image view, and we are going to do what we have been doing so far. I'm going to embed in an image here saying that tap to select a new picture, and the users will have to click on that to open the photo library and choose one of the images. So, that's easy to do. And I'm going to bring in one button as well, and I will name this button next rather than upload or save, because after that we're going to have to choose a location from the maps before we save this information. So, this will be our next button.

Of course we can put this next button on the bar button items as well. But right now, I believe we have space in here. So, I'm going to go for this one and say 'Reset to Suggested Constraints', and I believe it didn't reset to suggested constraints. Let me do it one more time. Here we go now, it's working. And I'm going to give some fixed width and height constraints to this view controller, not view controller, to this UIImageView as well.

Now, I need an image to place hold here as a way to indicate that users will have to tap this image view to select one picture. I'm going to do this in Sketch. And if you don't want to do that, you can just go to my GitHub page, and take my image from that GitHub page. So, as you can see, we have 286 to 300 over here. So, I'm going to give the exact same width and height to my image, and I'm going to choose something blue or green.

And again, we will have a basic design section in this course as well. After watching that section, you will be much more comfortable to do this kind of operation on Photoshop or Sketch Or Adobe XD. So, I believe we have to go for white, and call this tap to select picture or tap to select image. This is more than good for us right now. I'm going to export this. So, let me group this, and say selectimage or selectpicture. And let's export this as PNG, and I'm going to say 'Save'. And I'm going to delete this, because I won't use it later on.

So, let me bring in the selectimage.png into my assets. So, here you go. Now, I'm done. So let's go back to main.storyboard, and select that picture from this image properties, and here you go. Now it's okay. Now, I believe we have to add a Cocoa Touch class so that we can define everything in here to our class. So, let me come over here, and 'right' click say a 'New File...', choose 'Cocoa Touch Class'. And instead of ViewController, I'm going to go for something like AddPlaceVC or AddplaceViewController, because we're going to be adding places in this view controller. You can call this something like details or image view controller, something like choosing the options view controller. I'm going to go for AddPlaceVC. And I'm spending time in here because actually choosing the variable name and class names are important. Because in the real life examples, you will be working with multiple developers in big projects. So, you're going to have to come up with goods, view controller names like good variable names. So, please think about it before you just choose a random name.

So, come over here to main.storyboard, and choose the 'View Controller' and go to the identity inspector where you can find the AddPlaceVC and connect them together. So far, so good. So, let's do the segue from places we see to here and say 'Show'. And as you can see, we get our back button. And once we do that, it kind of distorted the whole constraints over here. So, let me put this down a little bit, and say 'Update Constraint Constants'. And now I believe this is okay.

So, let me open on the assistant editor, and go to AddPlaceVC, and bring in all the views one by one. So, let's delete this commented lines. Let's go to the name text. So, this is place name text. So this is going to be placeNameText and placeTypeText. So, let me bring in this one- placeTypeText. And for the third one, I'm going to go for placeAtmosphereText. So, the atmosphere, it's a wrong choice I believe, because it's long. But we can deal with it. So, let's go for placeImageView.

And finally we have to go with this next action button. So, nextButtonClicked. So, here you go. We have created our AddPlaceviewController, and we have created the Cocoa Touch class related to that view controller. Now we have to add a map view controller. So, that after user clicks on 'Next', they will see a map in which they will choose the location of the place they want to add, and we will get the coordinates and upload them to the PARs. So great, let's do that in the next lecture.

 

About the Author
Students
183
Courses
55
Learning Paths
3

Atil is an instructor at Bogazici University, where he graduated back in 2010. He is also co-founder of Academy Club, which provides training, and Pera Games, which operates in the mobile gaming industry.

Covered Topics