How to see UITableViewDelegate in Interface Builder?
I have 开发者_如何学JAVAa UIViewController that I've added UITableViewDelegate to. This controller has a corresponding nib. I've associated the two in IB. However, the nib's File's Owner doesn't show the tableview delegate or datasource. I have a similar controller and nib where the tableview delegate shows up fine in IB. I can't see any differences in the two.
What am I missing to make the tableview delegate and datasource show up in IB?
-- EDIT: ANSWER --
This project is tab bar based. For the second tab bar, I added a dedicated nib and connected the above mentioned UIViewController to it. The nib always loads but the tableview delegate doesn't do anything. This is because I need to remove the view connection for this controller made through the mainwindow nib, which is done automatically when the project is created. When a new tab bar project is created, each of the views are connected. Having the automatic view connection plus my custom view connection caused problems with the tableview delegate. IB even displays a little warning in the mainwindow, which I obviously didn't see.Your main view is now a type of UIView and not UITableView. So your file's owner will not show datasource or delegate.
For them to appear, you have to drag a table view and add it as a subview of the only view present. connect that tableview's delegate and datasource to the file's owner and it should all work.
UITableView delegate and datasource protocols belong to a UITableView - you'll only see them if you have a UITableView somewhere to attach to.
You might have possibly seen them appear in a file's owner elsewhere if you had a UITableViewController (which is a kind of UIViewController), which probably exposes those delegates in order to be able to set them for the internal UITableView it holds onto.
精彩评论