删除iphone上UItableview部分中的数据复制
为了删除表节视图中的重复数据,我现在正在这样做,我不知道这是否是好的,所以请帮助删除iphone上UItableview部分中的数据复制,iphone,Iphone,为了删除表节视图中的重复数据,我现在正在这样做,我不知道这是否是好的,所以请帮助 - (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath { //UILabel *labelb; UILabel *labela; UILabel *labelt; static NSString *FirstRowCellIdentifier
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//UILabel *labelb;
UILabel *labela;
UILabel *labelt;
static NSString *FirstRowCellIdentifier = @"A";
static NSString *FirstRowCellIdentifierb = @"Aa";
static NSString *OtherRowCellIdentifier = @"B";
static NSString *OtherRowCellIdentifierb = @"Bc";
static NSString *SecondRowCellIdentifier = @"C";
static NSString *SecondRowCellIdentifierb = @"Cb";
static NSString *SecondRowCellIdentifierc = @"Cc";
static NSString *CellIdentifier = nil;//@"Cell";
// NSLog(@"M I BEING CALLED");
if ([indexPath section] == 0 )
{
NSLog(@" 0");
CellIdentifier = FirstRowCellIdentifier;
}
if ([indexPath section] == 1 )
{
NSLog(@" 1");
CellIdentifier = FirstRowCellIdentifierb;
}
if ([indexPath section] == 2 )
{NSLog(@" 2");
CellIdentifier = OtherRowCellIdentifier;
}
if ([indexPath section] == 3 )
{
NSLog(@" 3");
CellIdentifier = OtherRowCellIdentifierb;
}
if ([indexPath section] == 4 )
{NSLog(@" 4");
CellIdentifier = SecondRowCellIdentifierb;
}
if ([indexPath section] == 5 )
{NSLog(@" 5");
CellIdentifier = SecondRowCellIdentifier;
}if ([indexPath section] == 6 )
{NSLog(@" 5");
CellIdentifier = SecondRowCellIdentifierc;
}
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
//number++;
// NSLog(@" NUMBER IS %d",number);
// if (cell != nil)
//if(number==1);
{
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
//
//cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
//appDelegate=(XMLAppDelegate*)[UIApplication sharedApplication].delegate;
//aBook=[appDelegate.books objectAtIndex:indexPath.row];
switch(indexPath.section)
{
case 0:
case 1:
}
为什么不只是一个字符串数组?数组索引将是节和字符串,即单元格标识符:
static NSArray * CellIdentifiers = [Array arrayWithObjects:@"A",@"Aa",...,nil];
CellIdentifier = [CellIdentifiers objectAtIndex:indexPath.section];
是的,但这是分配每个单元格部分新标识符的好方法吗??我的意思是,如果我使用NSlog2,那么每次我滚动我的表格时它都会打印,这可以被视为内存问题??这取决于单元格的样式是否相同。请参阅TableView编程指南:如果只是文本从一个单元格更改为另一个单元格,请使用相同的单元格标识符。它确实是文本,但我的图像在我几乎不滚动时也会被洗牌。。你认为解决这个问题的最好办法是什么