Found 208 Articles for IOS

How to align views at the bottom of the screen in iOS

Nishtha Thakur
Updated on 30-Jul-2019 22:30:25

1K+ Views

The recommended way and the modern way is to do using constraint. We will be using constraint to align the views at the bottom of the screen.Step 1: Open Xcode → New Projecr → Single View Application → Let’s name it “ViewAlignment”I’ll be using UIView, but you can use any UI component following the same steps.Step 2: Open Main.storyboard change the background color of ViewController (this we are doing for better understanding) and add UIView.Step 3: Add Constraints − Click on UIView → Add new constraints.While giving constraints we need to keep in mind 4 parameters, Xaxis, Yaxis, Height and ... Read More

While developing an iOS application you might have got a scenario where you require to send a text message and you would be baffling around with Why? How? And What?

Smita Kapse
Updated on 30-Jul-2019 22:30:25

64 Views

In this tutorial we will be focussing on how to send text message from your iOS application in Swift, where we will be sending a text message from your user’s phone number. While we cannot do this directly without the content of your user’s but we can display a precomposed message for the user to send which user can modify later if he wants to.So let’s get started, We will be using “MFMessageComposeViewController” class object to display the standard message composition interface inside your application.Before we present the composition interface, we will populate the fields with the basic initial message ... Read More

How to integrate a facebook login in swift for iOS App?

Fendadis John
Updated on 30-Jul-2019 22:30:25

340 Views

Social logins in applications have become a very common thing these days. Facebook login is one of them, in this article we’ll see how we can make use of facebook login, to access basic user information and login to the application.Implementing facebook login in an application is a series of multiple steps, out of which even a single step can not be skipped.The first step is to register as a developer on: https://developers.facebook.com/Once you sign up as a developer and complete the required steps to sign up, you will be taken to dashboard. Which at present looks like as shown ... Read More

How do you hide the onscreen keyboard in iOS App?

Rama Giri
Updated on 30-Jul-2019 22:30:25

318 Views

To hide a keyboard on screen we need to make use of some internal functions that are predefined in the iOS SDK. The keyboard appears on screen when we are typing in a text Field or textView. We need to make use of internal function according to the text field.For example if the current text field is tfOne, we can hide the text field using the code below:tfOne.resignFirstResponder()This code will hide the keyboard when ever called, we may call this on an action for a button or for gesture recognizer.This method is good for limited textFields, but we need to ... Read More

How to resize an UIImageView using Swift?

Rama Giri
Updated on 30-Jul-2019 22:30:25

3K+ Views

To resize an image in iOS using swift we’ll make use of frame.Let’s see this with help of an example.Create an empty project and add an empty Image view.Create its outlet.Add an image to your project and assign the image to image view.Initially when we run the application, it looks something like this.Now, let’s add code to resize the image.override func viewWillLayoutSubviews() {    let frame = CGRect(x: 10, y: 10, width: self.view.frame.width - 20, height: 300)    self.imgView.frame = frame }We will run this code in our viewWillLayoutSubviews method. This is how it looks on the device when we ... Read More

How do I load an image by URL on iOS device using Swift?

Fendadis John
Updated on 30-Jul-2019 22:30:25

572 Views

To load an image in iOS using swift we’ll make use of simple data Task session. The image needs to be loaded in background because it may be of any size and we don’t want it to stop our main view’s operations.Let’s see this with help of an example. Create an empty project and add an empty Image view.Create its outlet and then we’ll write the code to get image from an URL. This is how our application looks at the moment.Now, let’s add code to get image from an URL.func getData(from url: URL, completion: @escaping (Data?, URLResponse?, Error?) -> ... Read More

How to make an HTTP POST request on iOS App using Swift?

Rama Giri
Updated on 30-Jul-2019 22:30:25

872 Views

To make an http request in iOS we’ll make use of DataTask and sessions. We’ll create configuration, sessions, url, request, and dataTask objects. Let’s see the steps that we’ll go through.First of all we need to create a session object, which default configuration.let configuration = URLSessionConfiguration.default let session = URLSession(configuration: configuration)Then we need to create an URL Request of The type we need, it can be get, post, delete or put. In this example we are seeing ”POST” type.let url = URL(string: URLString) //let url = NSURL(string: urlString as String) var request : URLRequest = URLRequest(url: url!) request.httpMethod = "POST" ... Read More

How to check Location Manager is running or not in iOS App?

Fendadis John
Updated on 30-Jul-2019 22:30:25

314 Views

To check any services related to location in ios with swift we can use the CLLocationManager.In this example we’ll see how to check if the location manager is running or not. We’ll do this with help of an sample project. So, create a new project. First we need to create a locationManager object, so in your view controller.var locationManager = CLLocationManager()Now, we first of all we need to check if the location services are enabled on the device or not. To check this we’ll useCLLocationManager.locationServicesEnabled() function, which returns a Boolean value showing whether the location service on device is active ... Read More

How to make an HTTP request on iOS App using Swift?

Fendadis John
Updated on 30-Jul-2019 22:30:25

682 Views

To make an http request in iOS we’ll make use of DataTask and sessions. We’ll create configuration, sessions, url, request, and dataTask objects. Let’s see the steps that we’ll go through.The HTTP request can be of different types, it depends on what kind of request we want to make to our server. Below are the basic types of requests.“GET”, ”POST”, ”PUT”, ”DELETE” , we can make use of any of these according to our API. The basics remain same for each kind of request, which are shown below. Let’s see these examples with DELETE type of request.First of all we ... Read More

Dynamically change TableView Cell height in Swift

George John
Updated on 30-Jul-2019 22:30:25

6K+ Views

To change the height of tableView cell in ios dynamically, i.e resizing the cell according to the content available, we’ll need to make use of automatic dimension property. We’ll see this with the help of an sample project.Create an empty project and go to it’s viewController class, conform it to UITableViewDataSource and UITableViewDelegate.Now, In the below code, we will first create a table, then register a cell for that table, and add some table properties.We’ll set the table view delegate and table view datasource.Finally we’ll add the table view to view. Then we’ll call this function inside the viewDidLoad method ... Read More

Advertisements