Get an embedded UITableView from a container?

I am working with a library from github that requires the table view to be in the view controller.

Example: HidingNavigationBarManager(viewController: self, scrollView: tableView)

But my table view is not inside my VC, instead I have a container view with an embedded segue in the table view.

So how can I pass an inline table view that is inside my container view to a function:

HidingNavigationBarManager(viewController: self, scrollView: tableView)

      

+3


source to share


1 answer


If the ViewController ViewController has container items in it, it runs a method prepareForSegue

on the ViewController that contains the container items after viewDidLoad. There you can get the viewController link which is embedded in the containerView.

So, for example, you have a containerView that is associated with the viewcontroller of the TestViewController class:



override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

   var vc: AnyObject = segue.destinationViewController
    if vc .isKindOfClass(TestViewController) {
        NSLog("GOTCHA!")
    }
}

      

This way you can refer to tableView in TestViewController like forexample: vc.tableView

inside if

prepareForSegue method block.

+5


source







All Articles