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
    • 337
    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

    override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
            return 1
        }
        
       override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
            let mycell = tableView.dequeueReusableCellWithIdentifier("myCell", forIndexPath: indexPath)
        
    
            mycell.textLabel?.text = "my cell number is \(indexPath.row)"
            
            return mycell
            
        }
        
       override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
            return 10;
            
        }
        override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
            self.performSegueWithIdentifier("ShowDetail", sender: nil)      
        }
        override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
            
            if (segue.identifier == "ShowDetail") {
                
                let detail = segue.destinationViewController as! DetailViewController
                
                if let path = tableView.indexPathForSelectedRow {
                
                    detail.stringFromTable = "Hello you selected the value\(path.row + 1)"
                }  
            }  
    
    }

    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
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: