Redeem Now
Read More
Read now

UISplitViewController in swift 5

UISplitViewController is a container view controller used to display two view controllers in a hierarchical interface, like showing content in the first view controller and related information in the second view controller.

The iOS split view will show the two view controller content based on the size of the device, like if the device is in portrait orientation then it will allow you to see content in both view controller otherwise it will show only one view controller at a time.

Up till now we were able to use split view in iPad only but with introduction of iPhone 6 and iPhone 6+ which support larger screens we can now use this feature in iPhone too.

Create UISplitViewController  App

Step 1: Create a project in Xcode.

Step 2: Remove default view controller and drag a split view controller in Main.stroryboard.

This will add several elements in your project.

Create new files for Table view controller, Table view cell and Detail view controller.

Now, drag a label in to table cell and Details view controller and set the constraints.

Now, open Tableviewcontroller file and send the data into table view cell.

Now we need to write a code to show item details when click on it for that write code in DetailViewController.swift file like as shown below

Build and run. At this point, you should see your view controllers.

 

Now, set the didSelectRowAt delegate in the Table view controller and access the UILabel from the details view.

 

This is how we can use the UISplitViewController in swift to show the two side by side view controller based on our requirements.

. . .

Comment

Add Your Comment

Be the first to comment.

css.php
Hire Us!
Brief us about your requirements and we'll get back to you.
Woo! Hooy!
We have just recieved your project brief and our expert will contact you shortly.
Send Again
Close