如何在视图控制器中管理UI Table View

发布于 2025-01-07 14:38:15 字数 526 浏览 2 评论 0原文

我有一个简单的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

捶死心动 2025-01-14 14:38:15

首先,如果您想向 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文