2
我不知道該怎麼想......
我設置了我的主視圖來包含UITableView
。 (我使用一個UIPickerView以及在該視圖)UITableView不會調用numberOfRowsInSection也不cellForRowAtIndexPath
我將它定義爲符合協議:
UIPickerViewDelegate,
UIPickerViewDataSource,
UITableViewDataSource,
UITableViewDelegate
宣佈,在我看來的小時兩種方法:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
實施他們在米:
- (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;
}
我確實設置了我的viewDidLoad
代表:
searchTableView = [[UITableView alloc] init];
[searchTableView setFrame:CGRectMake(searchBar.frame.origin.x+10, 50, searchBar.frame.size.width-20, 300)];
searchTableView.delegate=self;
然而,不是numberOfRowsInSection或cellForRowAtIndexPath都被稱爲!
我在做什麼錯?
你設置數據源? – tomidelucca 2012-07-11 01:26:47