I have a custom collection view where the cell will have an image and how to label the label from the collection view when the cell is fast ,
Use representative pattern to resolve this. As an example:
Check sample code. The following sample opens an example of UITableViewController which is based on the example of UIViewController. Users can select on TableViewController and it will be sent to ViewController.
Protocol code:
Import UIKit Protocol SelectionTableViewControllerDelegate {func selectionDone (Controller: SelectionTableViewController, Selection: Sting)}
UIViewController Code :
Import UIKit class sample view controller: UIViewController, SelectionTableViewControllerDelegate {func selectionDone (Controller: SelectionTableViewController, Selection: string) {// Use Selection as you want}}
UITableViewController Code:
Class SelectionTableViewController: UITableViewContorller {var Rep: SelectionTableViewControllerDelegate? Overlays function table view (table view: UITableView, didSelectRowAtIndexPathindexPath: NSIndexPath) {give cell = self.tableView.cellForRowAtIndexPath (indexPath) selected Value = cell? .textLabel? .text self.delegate? .selectionDone (auto, selection: selectedValue!)}}
Hope this will help you get an idea.
No comments:
Post a Comment