Objective c UITableView没有';t调用节中的行数或索引路径中的行数
我不知道该怎么想…Objective c UITableView没有';t调用节中的行数或索引路径中的行数,objective-c,ios,xcode,Objective C,Ios,Xcode,我不知道该怎么想… 我将主视图设置为包含UITableView。(我在该视图上也使用UIPickerView。) 我将其定义为符合协议: UIPickerViewDelegate, UIPickerViewDataSource, UITableViewDataSource, UITableViewDelegate 在我的观点h中宣布了两种方法: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPa
我将主视图设置为包含
UITableView
。(我在该视图上也使用UIPickerView。)
我将其定义为符合协议:
UIPickerViewDelegate,
UIPickerViewDataSource,
UITableViewDataSource,
UITableViewDelegate
在我的观点h中宣布了两种方法:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
在m中实施:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell=[[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"] autorelease];
cell.textLabel.text = [NSString stringWithFormat:@"Test %d",indexPath];
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 5;
}
我确实在我的视图didload
中设置了代理:
searchTableView = [[UITableView alloc] init];
[searchTableView setFrame:CGRectMake(searchBar.frame.origin.x+10, 50, searchBar.frame.size.width-20, 300)];
searchTableView.delegate=self;
然而,从未调用过Section中的行数或索引路径中的行数
我做错了什么?设置数据源:
[searchTableView setDataSource:self];
你设置好数据源了吗?