简体   繁体   中英

UINavigationController -> UIViewController -> UIView -> UITableViewController?

Inside Interface Builder I have a UINavigationController, which contains a UIViewController, which has a UIView inside it. This main UIView has a bunch of labels as well as a few ImageViews and custom UIViews as well.

What I want to do though is throw a UITableView inside this main UIView. This UITableView will take up about half the screen in the UIView. I'm trying to add a UITableViewController below the UIView but everytime I do it, the UITableViewController object replaces my UIViewController object in IB??

What am I doing wrong?

I want:

    UINavigationController
      UIViewController
        UIView
          UITableViewController (since the UTableView will be inside the preceding UIView)

Where am I going wrong in this setup? When I try to add the UITableViewController in IB I get:

    UINavigationController
      UITableViewController (..err? Why's it replacing my ViewController?)

Thanks in advance!

After putting UITableView into UIView instead of UITableViewController, and then set table view's delegate and data source to UIViewController. Naturally, UIViewController should implements two protocol (table view deleate and data source).

You probably don't need table view controller at all. You have to add UITableView and implement all necessary data source and delegate methods in your view controller.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM