Hi every one Here I am going to describe the method to implement the split view Controller Its generally called “Drawer” in iOS Or Android. Generally people implement the UI for drawer in a single format which is shown the same in iPad or iPhone. Split view Controller is used to show the two views in a single display.

According to Apple Developers “Split View Controller is a container view controller that manages two panes of information. The first pane has a fixed width of 320 points and a height that matches the visible window height. The second pane fills the remaining space.”(As Shown in Figure Below.)

To implement the Split view controller follow the steps below : 

Step:1 Drag and drop the Spit view controller from the object bar : –

In the above image you see there are 4 view view controller are appear : Firstly made the initial view Controller to split view Controller. So you are only able to start the app from the split controller 

Step : 2 : Now make the new class  name (“MainViewController”)which inherit the Sub Class UITableViewController. That class contain all the delegate and dataSource method for table view . Assign the MainViewController to the Root View Controller in Main.StoryBoard

Step2 : Create Another Class named(Detail View Controller ) which inherit the Subclass UIViewController .And assign the class to the view controller .

Basically the split view controller work on the delegate. Delegate is used to send the message to one object to another.To implement the Delegate we make a protocol on mainViewController to tell the compiler that we will use delegate function any time when its required in the class.

Step :- 3 First, open Main.storyboard and embed the Detail View Controller into a Navigation Controller. You can do this by selecting the Detail View Controller and then selecting Editor/Embed In/Navigation Controller.(Shown in Figure Below)

Step:4 Now you have to create swift class window(key)+n->Swift->ModelForSplit.swift.

In ModelForSplit class we implement initialiser method that initialise the value for the , that consist the variable of name and description 

Step:5- Now We add the following code into the mainViewController Class.And it will look like that shown below.

Step6 :- Now you are ready to run the app . Select the iPad in simulator and run the app .

Hey nice you have done it.You are successfully implemented the split view controller

Note

In iPhone this will start from the detail view controller , So if you want to start from table Screen first ,then you should follow one more i.e. step create a new class which inherit the subclass UiSplitViewController and add the following code in class .(Assign the PrimaryViewController to the split view controller 

 

Thanks & Regards,

Rohit Gupta