The course is part of this learning path
In this course, we're going to create a Snapchat clone using structs and various advanced techniques of Firestore.
- Learn how to make a Snapchat clone
- Understand all the features of Snapchat and how to set them up
This course is intended for anyone who wants to learn how to develop apps on iOS.
To get the most out of this course, some basic knowledge of iOS development would be beneficial. We recommend that you take this course as part of the Developing Mobile Apps for iOS learning path.
Hi, within this lecture, we're going to take care of this UploadViewController, we want to choose a picture from photo gallery. So, we're going to just implement these features very fast because we have done it several times, from now on. So, I have to tap to select picture over here, so I'm going to create this inside of my sketch so that you can actually let people know that they have to click on this ImageView to select picture. Now as you can see, I'm doing that in sketch, so you can do that in Photoshop, you can do that in Paint, you can do that wherever you want. You can use my own picture from GitHub account. So, please yourself. So, I'm going to have a green file over here and I'm just going to add some text on this and I'm going to say something like tap to select picture, okay? So, let's say tap to select image, okay? So, let me make this a little bit bigger because I believe we have some room to go over that like this. I believe that's good. So, let me export this file so that we can use it in our ImageView. I'm going to name this something like select image, okay? I'm going to export this as PNG and I don't want to save this for web, I believe so let me uncheck this and save it. And here we go, now I can delete this and I have to bring this in. So, let me open my assess folder first and I'm going to bring this in. So, here we go. Now, let me go to my main storyboard because I'm going to bring in this image using my ImageView. Now user will know to tap here. So, let me go to my settings now, UploadViewController because in the UploadViewController we want to have a clickable ImageView. So, first thing to do is say, uploadImageView.isUserInteractionEnabled is true, okay? And then later on I'm going to create my gestureRecognizer as usual, so this will be a UITapGestureRecognizer and this will ask us for a target and a selector, so target will be self, selector will be a function. So, I'm going to create that function over here. So, this is an objc func choosePicture, okay? And I'm going to give this as a selector over here. Later on, I can just say uploadImageView.addGestureRecognizer and I'm going to add our gesture recognizer over here. Later on, I'm going to create a picker. So, this will be a UIImagePicker, okay? So, UIImagePickerController. Yes, this one and this picker will have the delegate itself and once we do that we have to come over here and assign this ViewController to be a UIImagePickerControllerDelegate and the UINavigationControllerDelegate, okay? So, once we do that, we can come over here and specify the source type as well as photo library and then I can just present this and say self.present. So, present this picker with of course animation and without any completion. So, after we have to specify what will happen once user chooses the picture. In order to do that, we're going to call a function called didFinishPicking, okay? So, this one. Remember this gives us an info dictionary and we're going to say uploadImageView.image will come from this info dictionary and we are looking for an original image and we're going to cast this as a UI image. So, we can dismiss this later on and animation will be true, completion will be nil. So, let's test that. Let's open our simulator, and if we can see the picture in our UIImageView then it means that we're going to be ready to upload our picture to the server and that's where it gets exciting, okay? Because we get to work with models, we get to see the advanced features of Firebase. So, let me click over here and open any photo from photo library, and here we go. Now we can see it. Now all we have to do is just to implement this upload feature. And again this will be exciting because we're not going to upload this feature as it is as we have done before, we have to figure out a way to upload the username to the Firestore. And also we have to figure out a way to group all of this picture into one post so that we won't see some Instagram-like feed, but rather we're just going to see some Snapchat-like feed, and we're going to do that within the next lecture.
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.