如何調用xcode中的新函數,並且我正在執行此代碼來填充具有註釋標題的表視圖,但函數被多次調用並且表格單元格中填充了所有重複的值,如何所謂在Xcode的功能,如何從停止此功能獲取調用不止一次xcode
- (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];
}
NSLog(@"this is a test text ");
NSMutableArray *annotations = [[NSMutableArray alloc] init];
int i=0;
if(indexPath.section == 0)
{
for(iCodeBlogAnnotation *annotation in [map annotations])
{
i++;
NSLog(@"this is the no %d",i);
[annotations addObject:annotation];
}
cell.textLabel.text = [[annotations objectAtIndex:indexPath.row] title];
}
return cell;
}
任何幫助深表感謝, 感謝您的幫助提前
Xcode不調用函數。 – BoltClock 2011-06-14 16:34:04
你能幫我嗎我怎麼才能找出爲什麼for循環運行不止一次,謝謝 – jarus 2011-06-14 16:36:57
每次調用方法都會運行'for'循環,每當UITableView需要一個單元時,循環就會發生。 – Anomie 2011-06-14 16:40:15