3
我已經創建了插入tableview.And 12行插入fine.When後插入我行我不tableview.So的滾動過程中我與indexpath行檢查要在文本中的任何變化都有的UITableViewCell的價值示例應用程序,如果它有值意味着返回該單元格,否則我們創建新的UITableViewCell。的cellForRowAtIndexPath總是返回零
我的示例代碼如下
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSLog(@"GlobalCount = %d",GlobalCount);
return GlobalCount;
}
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *obj = (UITableViewCell*)[tableView cellForRowAtIndexPath:indexPath];
if(obj!=nil)
{
NSLog(@"cell indexpath row = %d",indexPath.row);
NSLog(@"cell text = %d",obj.textLabel.text);
return obj;
}
else {
NSLog(@"obj==nil");
}
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
if([DataTable count]>0)
cell.textLabel.text = [DataTable objectAtIndex:0];
// Configure the cell.
return cell;
}
什麼我的目標是,我不想更新任何文本(或UITableViewCell)已經創建ated indexpath行。所以(細胞),我可以的cellForRowAtIndexPath檢查這一點,但它總是返回nil.If我缺少什麼?
我檢查使用此行
UITableViewCell *obj = (UITableViewCell*)[tableView cellForRowAtIndexPath:indexPath];
if(obj!=nil)
PLZ幫助我嗎?
在此先感謝......
後,我插入正常工作的所有行,然後我從數據表中(其nsmutablarray)。現在我滾動表沒有在tableview.So我插入的數據順序並不在tableview中一些文字修改刪除的所有對象。任何想法PLZ幫助我? – Tamil 2010-09-28 12:34:21
你爲什麼要做一些像清理數據源一樣的東西,還想讓表格顯示它的舊版本?如果你希望你的數組被清除,並且你的表包含舊值,那麼首先將它複製到你的數據源然後清除它。 – VdesmedT 2010-09-28 12:41:10
Ya。你是對的。爲什麼我想清除數據意味着,我得到的數據超過udp接收。所以,我的數據大小是去大和大,其掛在我application.So我想從數據源插入一行並刪除該數據array.So沒有大量的數據,在我array.This是我的想法。任何幫助? – Tamil 2010-09-28 12:47:43