0

UI テーブル ビューで異なる見出し (ヘッダー) を使用して 3 つのセクションを作成しました。現在、データをセルに直接ロードしています。しかし、section3(indexPath.section == 2) を使用していません。誰でも私の間違いを教えてもらえますか。

これがコードです。

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


static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [mainTable dequeueReusableCellWithIdentifier:CellIdentifier];
//  cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil];
if (cell == nil)
{




    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];

    if(indexPath.section == 0)
    {

        cell.textLabel.text = @"Insite  Mobile App Delegate";


        cell.detailTextLabel.text = @"Hi, Make following Changes in";

        cell.textLabel.textColor = [UIColor whiteColor];

        UILabel *dateLabel = [[UILabel alloc]initWithFrame:CGRectMake(180, -8, 300, 40)];
        dateLabel.textColor = [UIColor grayColor];
        dateLabel.font = [UIFont systemFontOfSize:12];
        dateLabel.backgroundColor = [UIColor clearColor];
        dateLabel.text = @"Feb 06, 2013";

        [cell addSubview:dateLabel];




    }

    if(indexPath.section == 1)
    {


        cell.textLabel.textColor = [UIColor whiteColor];
        cell.textLabel.text = @"Insite  Mobile App Delegate";

            cell.detailTextLabel.text = @"Hi, Make following Changes in";



        UILabel *titleTextField = [[UILabel alloc]initWithFrame:CGRectMake(10,-10, 300, 40)];
        titleTextField.text = @"Anary, Zubin";
        titleTextField.textColor = [UIColor whiteColor];
        titleTextField.backgroundColor = [UIColor clearColor];
        titleTextField.font = [UIFont boldSystemFontOfSize:16];
        [cell addSubview:titleTextField];



        UILabel *dateLabel = [[UILabel alloc]initWithFrame:CGRectMake(180, -8, 300, 40)];
        dateLabel.textColor = [UIColor grayColor];
        dateLabel.font = [UIFont systemFontOfSize:12];
        dateLabel.backgroundColor = [UIColor clearColor];
         dateLabel.text = @"Feb 06, 2013";

        [cell addSubview:dateLabel];

    }


    else if(indexPath.section == 2)
    {


        cell.detailTextLabel.text = @"Daily Mobile Touch Base";
        cell.textLabel.textColor = [UIColor whiteColor];
        cell.textLabel.text = @"1:00 pm – 1:30 | M1 - 5026 ";
        cell.imageView.image = [UIImage imageNamed:@"iPhone_webx.png"];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    cell.imageView.image = [UIImage imageNamed:@"iPhone_webx.png"];


    }






}cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;  
return cell;
}






- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{if(section==0){ return 4;}

else if(section==1)
{
    return 3;
}
else if (section==2)
{
       return 3;
}

else
    return 0;
    }

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{return 3;}
4

1 に答える 1

0

これを試して

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath     *)indexPath
{
static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];

    if(indexPath.section == 0)
    {
      cell.textLabel.text = @"Insite  Mobile App Delegate";

      cell.detailTextLabel.text = @"Hi, Make following Changes in";
      cell.textLabel.textColor = [UIColor whiteColor];

      UILabel *dateLabel = [[UILabel alloc]initWithFrame:CGRectMake(180, -8, 300, 40)];
      dateLabel.textColor = [UIColor grayColor];
      dateLabel.font = [UIFont systemFontOfSize:12];
      dateLabel.backgroundColor = [UIColor clearColor];
      dateLabel.text = @"Feb 06, 2013";
      [cell addSubview:dateLabel];
    }

    if(indexPath.section == 1)
    {
      cell.textLabel.textColor = [UIColor whiteColor];
      cell.textLabel.text = @"Insite  Mobile App Delegate";
      cell.detailTextLabel.text = @"Hi, Make following Changes in";
      UILabel *titleTextField = [[UILabel alloc]initWithFrame:CGRectMake(10,-10, 300, 40)];
      titleTextField.text = @"Anary, Zubin";
      titleTextField.textColor = [UIColor whiteColor];
      titleTextField.backgroundColor = [UIColor clearColor];
      titleTextField.font = [UIFont boldSystemFontOfSize:16];
      [cell addSubview:titleTextField];

      UILabel *dateLabel = [[UILabel alloc]initWithFrame:CGRectMake(180, -8, 300, 40)];
      dateLabel.textColor = [UIColor grayColor];
      dateLabel.font = [UIFont systemFontOfSize:12];
      dateLabel.backgroundColor = [UIColor clearColor];
      dateLabel.text = @"Feb 06, 2013";
      [cell addSubview:dateLabel];
    }
    if(indexPath.section == 2)
    {
      cell.detailTextLabel.text = @"Daily Mobile Touch Base";
      cell.textLabel.textColor = [UIColor whiteColor];
      cell.textLabel.text = @"1:00 pm – 1:30 | M1 - 5026 ";
      cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
      cell.imageView.image = [UIImage imageNamed:@"iPhone_webx.png"];
    }
  cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;  
  return cell;
}
于 2013-02-20T18:02:17.473 に答える