Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • UiSplitView Controller in Swift

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 414
    Comment on it

    To Create a SplitViewController in swift follow the steps:-

    1- Create a new Project.

    2- Add a splitViewController.

    3- Create a cocoaTouch Class inherits from UIViewController named as DetailViewController

    4- Create another CoCoatouchClass that inherits from UITableViewController names as SideTableViewController

    5- Configure the SideTableViewController as

    1. override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
    2. return 1
    3. }
    4. override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    5. let mycell = tableView.dequeueReusableCellWithIdentifier("myCell", forIndexPath: indexPath)
    6.  
    7. mycell.textLabel?.text = "my cell number is \(indexPath.row)"
    8. return mycell
    9. }
    10. override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    11. return 10;
    12. }
    13. override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    14. self.performSegueWithIdentifier("ShowDetail", sender: nil)
    15. }
    16. override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    17. if (segue.identifier == "ShowDetail") {
    18. let detail = segue.destinationViewController as! DetailViewController
    19. if let path = tableView.indexPathForSelectedRow {
    20. detail.stringFromTable = "Hello you selected the value\(path.row + 1)"
    21. }
    22. }
    23.  
    24. }

    6- Add a label on DetailViewController and create iboutlet for that label and also create a variable named var stringFromTable = String?()

    7- in DetailViewController set the text as  myTextLabel?.text = stringFromTable

    8- Create a segue from SideTableViewController (Show Detail Type) and named it is ShowDetail

     

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: