title: TableView Behaving Weirdly
body: <p>My tableView (phpush) behaves very unusually. The cell from section 0 randomly appears at different rows, and sometimes disappears from the top of the table. Here are some methods that I think may be causing the problem:</p>
  
  <pre><code>-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  
      static NSString *CellIdentifier = @"Cell";
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  
      if (tableView==_phpush) {
  
          if (indexPath.section==0) {
  
              UIButton *pushButtonDate;
              UIButton *pushButtonPush;
              UIButton *edit;
  
              if (cell == nil) {
  
                  cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
                  pushButtonPush = [UIButton buttonWithType:UIButtonTypeRoundedRect];
                  [pushButtonPush addTarget:self action:@selector(pushButtonPushPressed:)forControlEvents UIControlEventTouchUpInside];
                  [pushButtonPush setTitle:@"Push-Ups" forState:UIControlStateNormal];
                  pushButtonPush.frame = CGRectMake(150,7,97,30);
                  pushButtonDate.tag = 3;
                  [cell.contentView addSubview:pushButtonPush];
  
                  pushButtonDate = [UIButton buttonWithType:UIButtonTypeRoundedRect];
                  [pushButtonDate addTarget:self action:@selector(pushButtonDatePressed:)forControlEvents: UIControlEventTouchUpInside];
                  [pushButtonDate setTitle:@"Date" forState:UIControlStateNormal];
                  pushButtonDate.frame = CGRectMake(11,7,97,30);
                  pushButtonDate.tag = 4;
                  [cell.contentView addSubview:pushButtonDate];
  
                  edit = [UIButton buttonWithType:UIButtonTypeRoundedRect];
                  [edit addTarget:self action:@selector(editButtonPressed:)forControlEvents:UIControlEventTouchUpInside];
                  [edit setTitle:@"Edit" forState:UIControlStateNormal];
                  edit.frame = CGRectMake(200,7,97,30);
                  edit.tag = 5;
                  [cell.contentView addSubview:edit];
              }
              else {
                  pushButtonPush = [cell.contentView viewWithTag:(3)];
                  pushButtonDate = [cell.contentView viewWithTag:(4)];
                  edit = [cell.contentView viewWithTag:5];
              }
              return cell;
          }
          else {
              UILabel *pushLabel;
              UILabel *pushLabel2;
              if (cell == nil) {
                  cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
                  pushLabel = [[UILabel alloc]initWithFrame:CGRectMake(150,7,97,30)];
                  pushLabel2 = [[UILabel alloc]initWithFrame:CGRectMake(10,7,150,30)];
                  NSArray *array;
                  if (sortByDate==true) {
                      array = [[pushDictionary allKeys]sortedArrayUsingSelector
                               :@selector(localizedCaseInsensitiveCompare:)];
                  }
                  else {
                      array = [pushDictionary keysSortedByValueUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
                  }
                  pushLabel.text = [pushDictionary valueForKey:[array objectAtIndex:indexPath.row]];
                  NSString *pushLabel2String = [[array objectAtIndex:indexPath.row] substringToIndex:MIN(10, [[array objectAtIndex:indexPath.row] length])];
                  NSArray *pushLabel2Array = [pushLabel2String componentsSeparatedByString:@"-"];
                  pushLabel2.text = [NSString stringWithFormat:@"%@/%@/%@",[pushLabel2Array objectAtIndex:1],[pushLabel2Array objectAtIndex:2],[pushLabel2Array objectAtIndex:0]];
                  pushLabel.tag = 1;
                  pushLabel2.tag = 2;
                  [cell.contentView addSubview:pushLabel];
                  [cell.contentView addSubview:pushLabel2];
              }
              else {
                  pushLabel = [cell.contentView viewWithTag:1];
                  pushLabel2 = [cell.contentView viewWithTag:2];
              }
              return cell;
              }
          }
      else {
          if (cell == nil) {
              cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
          }
          else {
  
          }
          return cell;
      }
  }
  
  - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
      if (tableView==_phpush) {
          return 2;
      }
      return 1;
  }
  
  -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
      if (tableView==_phpush) {
          if (section==0) {
              return 1;
          }
          return  [pushDictionary allKeys].count;
      }
      return 1;
  }
  </code></pre>
  
  <p>I'm wondering if there are any big mistakes I am making that would be causing this problem. I am pretty new to iOS programming, so please forgive me if I have made an obvious mistake. Do I need to post more of my code?</p>
  
  <p>Thanks,</p>
  
  <p>Jordan</p>