title: Is it possible to have two different UiTableViewCells in one UiTableView?
body: <p>I'm having an issue and would like to know if what I am trying to do is even possible. </p>
  
  <p>I have a ViewController that has a UITableView as a subview. I then loaded a custom cell and it worked fine. However, I needed another custom cell in the same tableview - this second cell has a separate nib as well. </p>
  
  <p>Is this possible?</p>
  
  <p>Two different custom cells in on section in a UITableView? </p>
  
  <p>I did try something like this:</p>
  
  <pre><code>- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath      *)indexPath
  {
      static NSString *CellIdentifier1 = @"ContentCell";
      static NSString *CellIdentifier2 = @"SpaceCell";
  
      // Space Cell
      if (indexPath.row== 0) {
          CellSpace *cell = (CellSpace *)    [tableViewdequeueReusableCellWithIdentifier:CellIdentifier2];
          return cell;
      }
  
      // Content cell
      else {
          CellView *cell = (CellView *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier1];
          // Configure cell
          return cell;
      }
  }
  </code></pre>
  
  <p>However it seems the else statement is never fired and I normally get a crash saying the method returned nil. </p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I used the advice and code here and came up with this: </p>
  
  <pre><code>#pragma mark - UITableView Delegate Methods 
  
  -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  {
  
      return 160;
  }
  
  -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  {
      return 22;
  }
  
  -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  {
      return 1;
  }
  -(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  
  
      static NSString *CellIdentifier1 = @"UsernameCell";
      static NSString *CellIdentifier2 = @"PasswordCell";
  
      if(indexPath.row == 0) {
  
  
          BBUsernameRegistrationCell *cell = (BBUsernameRegistrationCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier1];
          if(cell == nil) {
              NSArray *nib = [[NSBundle mainBundle] loadNibNamed:CellIdentifier1 owner:self options:nil];             // set properties
              cell = nib[0];
          }
              // set properties
          return cell;
      }
  
          // Content cell
      else {
          BBPasswordTableViewCell *cell = (BBPasswordTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier2];
          if(cell == nil) {
              NSArray *nib = [[NSBundle mainBundle] loadNibNamed:CellIdentifier2 owner:self options:nil];             // set properties
              cell = nib[0];
          }
              // set properties
          return cell;
      }
  }
  </code></pre>
  
  <p>However I only see the first Cell in my tableview. If I switch the cells around the second one loads. But not both at the same time. Does anyone have any idea why?</p>