我知道這個問題一再被問過。我試過所有給定的解決方案,但仍然無法正常工作。我已經設置了數據源和委託到我的表視圖,並將其設置爲我的指針。ReloadData不會觸發cellForRowAtIndexPath
這裏是我的代碼:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSLog(@"%i", resultSoap.count);
return resultSoap.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell.
NSString *cellValue = [resultSoap objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
NSLog(@"Celldisplay");
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
我已經在我的viewDidLoad:
方法稱爲reloadData
。事情是,它發射了numberOfRowsInSection:
方法,我得到的行數是正確的,但它並沒有觸發這個cellForRowAtIndexPath:
方法。
任何解決方案?
它返回多少行?在調試模式下,你能看到resultSoap的內容嗎? – Peres 2011-07-07 10:15:14