开发者

How to make a derived UITableVIew work

I've made a new class in my Xcode project which is derived from UITableView

I then drag a UITableView from in the interface builder onto my view and change the class of the object to my derived class. Then I drag the outlet from the table to the files owner and hook it up to an outlet variable in my main view, which is of the same type as my derived class.

How do I also set up the datasource and delegate so that they belong to the derived class?

I've got two table views on my main viewcontroller, and one of them uses that controller itself which works fine. The delegate and datasource is the file owner of the view controller.

But my other table view will be for different data, so I want it to use the datasource and delegate which is implemen开发者_JS百科ted on my derived tableview.


When you click on the UITableView-derived object are you not able to see the delegate and datasource members under the Table View Connections pane of the Inspector window? It should be as simple as dragging a connection from each to file's owner, or whatever object you want to make delegate/datasource. I've seen them go away when all you do is change the class type of an object, but if you write headers and make sure your class says that it is derived from UITableView then return to IB I believe you will see them again.

(apparently IB2 used to handle this the way you expected - in IB3 it is best to derive in Xcode first, then use the derived class in IB)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜