如何在视图控制器中管理UI Table View
我有一个简单的 UI 视图,其中包含一些项目。我想在其中放置一个表视图。
谁能用简单的步骤向我解释我必须写什么才能管理它?
我有另一个 UITableView,其中包含元素、行等。问题是在 UI 视图中实现 TableView:我不知道如何从那里添加行等。
我尝试执行以下操作,但没有成功:
@interface SecondViewController : UIViewController <UITableViewDelegate> {
UITextField *indirizzo;
NSMutableData *data;
UIButton *compra;
然后在 .m 文件中实现特定方法,例如
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 10;
}
但表不会更改。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,如果您想向 UITableView 添加行,您需要将 UIViewController 声明为 tableView DataSource 而不是委托。 (委托用于其他内容)
您应该查看 表格视图编程指南
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