How to manage UI Table View in View Controller

余生颓废 提交于 2019-12-11 10:50:15

问题


I've got a simple UI View, with some items in it. I'd like to place in it a Table View.

Can anybody explain me with easy steps what do I have to write in order to manage it?

I have another UITableView with elements in it, rows etc. The problem is implementing a TableView in a UI View: I don't know how to add rows etc from there.

I tried, with no success, to do the following:

@interface SecondViewController : UIViewController <UITableViewDelegate> {
UITextField     *indirizzo;
NSMutableData   *data;
UIButton *compra;

and then Implementing, in the .m file, the specific methods like

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 10;
}

But the table doesn't change.


回答1:


Well for start if you want to add rows to a UITableView you need to declare your UIViewController as the tableView DataSource not delegate. (delegate is for other stuff)

You should go over the Table View Programming Guide



来源:https://stackoverflow.com/questions/9376946/how-to-manage-ui-table-view-in-view-controller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!