jadval ko'rinishi :: maxsus katakdagi maxsus yorliqni o'chira olmadi

Mening iPhone ilovamda,

Jadval ko'rinishida

Menda bitta hujayrada ikkita yorliq bor.

  1. sukut bo'yicha textLabel.
  2. Maxsus yorliq

Ma'lumotlar massivdan o'chirilmoqda, bu yaxshi ...

Mana kod ..

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    //Get the Log Id for the sections. From Section Array
    int logID=0;
    if(indexPath.row==0)
    {
        NSLog(@"Time Array %@",timeArray);
        logID=[[[sectionArray objectAtIndex:indexPath.section] valueForKey:@"logID"] intValue];
        NSPredicate *p=[NSPredicate predicateWithFormat:@"logID==%d",logID];
        fillRows=nil;
        fillRows= [[timeArray filteredArrayUsingPredicate:p] mutableCopy];
    }



    static NSString *CellIdentifier = @"Cell";



    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];

    }



//Show Current Time.
//"If condition for not to go for Array Index Out of Bound".
if(indexPath.row<[fillRows count])
{
//Log CurrentTime    
    cell.textLabel.text=[[fillRows objectAtIndex:indexPath.row] valueForKey:@"logCurrentTime"];
    [cell.textLabel setTextColor:[UIColor whiteColor]];
//Log Duration.   
   UILabel *lblDuration=[[[UILabel alloc] initWithFrame:CGRectMake(110, 11, 60, 21)] autorelease];
   [lblDuration setTextColor:[UIColor whiteColor]];
        [lblDuration setBackgroundColor:[UIColor clearColor]];
        [lblDuration setFont:[UIFont boldSystemFontOfSize:18]];
   lblDuration.text=[[fillRows objectAtIndex:indexPath.row] valueForKey:@"logDuration"];
        [cell.contentView addSubview:lblDuration];
   }

    return cell;
}

Oldindan rahmat :)


person Arpit B Parekh    schedule 29.12.2011    source manba


Javoblar (3)


Javob: jadvaldan o'chirilgan katak yorlig'i nima uchun hujayraga yopishib qolgan ...

Ikki qator kodlarni sharhlaganimni ko'ring ......

Qaerda hujayra==nol..

  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {

        //Get the Log Id for the sections. From Section Array

        static NSString *CellIdentifier = @"Cell";



        **UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
     //   if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];

       // }**



    /if(indexPath.row<[fillRows count])
    {
    //Log CurrentTime    
        cell.textLabel.text=[[fillRows objectAtIndex:indexPath.row] valueForKey:@"logCurrentTime"];
        [cell.textLabel setTextColor:[UIColor whiteColor]];
    //Log Duration.   
       UILabel *lblDuration=[[[UILabel alloc] initWithFrame:CGRectMake(110, 11, 60, 21)] autorelease];
       [lblDuration setTextColor:[UIColor whiteColor]];
            [lblDuration setBackgroundColor:[UIColor clearColor]];
            [lblDuration setFont:[UIFont boldSystemFontOfSize:18]];
       lblDuration.text=[[fillRows objectAtIndex:indexPath.row] valueForKey:@"logDuration"];
            [cell.contentView addSubview:lblDuration];
       }

        return cell;
    }
person Arpit B Parekh    schedule 29.12.2011

  if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
   }
 if(indexPath.row<[fillRows count])
 {
        [lblDuration setTextColor:[UIColor whiteColor]];
        [lblDuration setBackgroundColor:[UIColor clearColor]];
        [lblDuration setFont:[UIFont boldSystemFontOfSize:18]];
        [cell.contentView addSubview:lblDuration];

 }

Buni sinab ko'ring..

person Ali3n    schedule 29.12.2011

yechimingiz uchun jadvalning delegat usulidan foydalaning

  • (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{ if (editingStyle == UITableViewCellEditingStyleDelete) {[arraytableDelete) {[Arayttable;x[Aload.Ob] ];}}

siz xohlagan narsani olasiz.

person user1072740    schedule 29.12.2011
comment
Yo'q, bu massiv ob'ekti to'g'ri olib tashlanganiga o'xshamaydi, faqat oldingi maxsus yorliq o'chirilgandan keyin ham qatorga yopishtirilgan ... - person Arpit B Parekh; 29.12.2011
comment
Quyidagi kabi katakchani ajrating va qarang. statik NSString *CellIdentifier = @Cell; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; agar (hujayra == nil) { hujayra = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];} - person user1072740; 29.12.2011