gpt4 book ai didi

iphone - UITableViewDataSource 委托(delegate)

转载 作者:行者123 更新时间:2023-11-28 22:30:16 26 4
gpt4 key购买 nike

我从 Xcode 模板创建了一个新的主从应用程序

我发现主界面(在本例中为 BirdMasterViewController)继承自 UITableViewController,和 UITableViewController 符合 UITableViewDataSource 协议(protocol)

所以我可以指定像这样的方法

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}

但我没有在 BirdMasterViewController 上找到 set delegate to _dataSource 变量,比如

xxxxxx._dataSource = self; or setDataSource: self

设置_dataSource对象

// to this
id <UITableViewDataSource> _dataSource;

为什么代表团能跑?

最佳答案

在您的 .h 文件中添加委托(delegate),然后使用您的委托(delegate)方法:

@interface BirdMasterViewController : UIViewController<UITableViewDelegate,UITableViewDataSource>

关于iphone - UITableViewDataSource 委托(delegate),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17650150/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com