2016-11-03 1 views
-1

2 개 사용자 정의 셀을 만들어이 들어있는 tableview이 redCellblueCell을목표 - C :</p> <p>-2 사용자 정의 셀 : jQuery과

-2 버튼 : redButtonblueButton 화면 하단에.

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

     if(indexPath.section == 0) { 
      RedTableViewCell *redCell = (RedTableViewCell *)[tableView dequeueReusableCellWithIdentifier:BlockListTableViewCellIdentifier forIndexPath:indexPath]; 
      Red *red = (Red *)[self.reds objectAtIndex:indexPath.row]; 

      return redCell; 
     } 
     else 
     { 
      BlueTableViewCell *blueCell = (BlueTableViewCell *)[tableView dequeueReusableCellWithIdentifier:RestBlockTableViewCellIdentifier forIndexPath:indexPath]; 
      Blue *blue = [self.blues objectAtIndex:indexPath.row]; 

      return blueCell; 
     } 

     return nil; 
    } 

My TableView

나는 내가 redButton redCell 추가 = 을 클릭하면, blueCell 추가 blueButton = 을 클릭 것을 원한다.

P/S : 배경색을 변경하고 싶지는 않지만 2 개의 다른 셀이 필요합니다.

+0

내 질문에 내가 왜 내 자신을 향상시킬 수 있는지 알고 싶습니다 downvotes받을 바랍니다 바랍니다. 고마워요. – VMCuongOnStackOverflow

+0

귀하의 질문에 불명확하며 귀하의 의견을 반영하지 않습니다. (추신 : 나는 투표를하지 않았지만 그 이유가 될 수있다) – Larme

+0

@Larme 고맙습니다. 나는 그것을 편집 할 것이다. – VMCuongOnStackOverflow

답변

2

귀하의 불명확 한 질문에 대해 다음과 같이 가정합니다.

빨간색 셀에 빨간색 버튼이 있으며이 빨간색 버튼을 클릭하면 새 빨간색 셀을 추가 할 수 있습니다. 파란색 셀과 유사합니다.

솔루션 :

내부, 빨간색 (또는 파란색) 버튼 액션,

  1. 당신의 self.reds (또는 self.blues) 배열
  2. 다시로드의 tableview
  3. 에 새 항목을 추가

또한 numberofRowsinSection은 섹션 0에 대해 self.reds.count를 반환하고 다른 섹션에 대해서는 self.blues.count를 반환해야합니다.