簡體   English   中英

刪除iPhone上UItableview節中的數據復制

[英]remove replication of data in UItableview Section on iphone

為了刪除表截面視圖中的重復數據,我現在正在這樣做,我不知道這是否很好,請幫忙

- (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];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM