How to fill data in UItableview in popover from UIViewcontroller?

μολὼν.λαβέ

I think this is an easy question. I've looked at other solutions but they to miss a key step for me.

IOS: fill a popover with a tableview

How to shove an array of values into an empty table in a popup?

The data is loaded properly and returned in my variable listOfFiles and the popover successfully launches with an empty table.

Now I'm missing the concept of how to get a reference to the UITableview? in my popover to populate it with data from a plist?

Do I need to add UITableViewDataSource, UITableViewDelegate to my UIViewController?

     //MARK:buttons to save and load defaults
      @IBAction func loadState(sender: UIButton) {

        if(dbg){println("loaded State")}

        //get list of plist files
        var listOfFiles: [String] = getSavedState()

        if(dbg){
          for index in listOfFiles {
            println("file name is \(index)")
          }
        }

//how to shove the data into the table??


        //MARK:idPopupFileTable
        let popoverVC = storyboard?.instantiateViewControllerWithIdentifier("idPopupFileTable") as UIViewController
        popoverVC.modalPresentationStyle = .Popover
        popoverVC.preferredContentSize = CGSizeMake(300, 200)

        if let popoverController = popoverVC.popoverPresentationController {
          popoverController.sourceView = sender
          popoverController.sourceRect = sender.bounds
          popoverController.permittedArrowDirections = .Any
          popoverController.delegate = self
        }
        presentViewController(popoverVC, animated: true, completion: nil)

      }

I've tried many ways but can't seem to get an IBOutlet from the popoverVC to the table. I can set up referencing outlets as seen below but cannot seem to create IBOutlet.

popupVC

Here is what the popoverVC looks like on the Storyboard, there is no direct segue connection to the mainVC.

enter image description here

enter image description here

rdelmar

Your popoverVC should have an IBOutlet to its table, and should implement the data source and delegate methods. That controller should also have an array property (called dataArray in my code below) that you can pass your array to when you create popoverVC.

let popoverVC = storyboard?.instantiateViewControllerWithIdentifier("idPopupFileTable") as UIViewController
popoverVC.modalPresentationStyle = .Popover
popoverVC.preferredContentSize = CGSizeMake(300, 200)
popoverVC.dataArray = liseOfFiles

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to fill an object from a class with data from JSON data?

Pass data to and from Popover in Swift

Swift UITableView: How to Load data from JSON

How to use a static UITableView inside a UIViewController?

how to open a popover from another popover? -jquery

How to fill UITableView with a data from Dictionary. Swift

Use Realm data to fill the UITableView (table)?

how to fill textbox with data from database

how to change a UILabel of a UIViewController from another UIViewController

iOS How to pass data from UIViewController to destinationViewController

How to display data saved in core data entity on a UITableView when the ".h" file class is UIViewController and NOT UITableViewController

How to reload data from a specific NSMutableArray into a UITableView

How to fill TableView with data from another ViewController

How to filter repeated data from a UITableView

ios - Action from UITableView to a UIViewController

How to get the data from the first cell in a UITableView?

How fill form data from Dropdown?

Passing data with segue from UITableView to UIViewController

How to get a popover from a popover in bootstrap

How to Display data from a UIDatePicker into a UITableView?

How to fill ListView in javaFX with data from URL?

How to fill and object with data from an array in javascript

update UIViewController in Real Time from Popover Viewcontroller in Swift 4

How to pass data from one UIViewController to another one through UITapGestureRecognizer

Get Data from UIViewController to Another UIViewController

How to fill a FindDropdown with data from api in Flutter?

How to fill a JTable with data from a HashMap?

How to fill a form with fetched data from an API?

Popover API: How to stop the popover from closing