over 6 years ago
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
Starting with Chrome version 45, NPAPI is no longer supported for Google Chrome. For more information, see Chrome and NPAPI (blog.chromium.org).
Firefox and Microsoft Internet Explorer are recommended browsers for websites using java applets.
Chrome Version Support
Are you sure, you want to delete this comment?
Sign up using
0 Comment(s)