Я прошел через мой отладчик и заметил, что мой код будет возвращать только одну пользовательскую ячейку из моего tableView: cellForRowAtIndexPath: метод. Я не знаю почему или как заставить его вернуть оба пользовательских элемента, которые я хочу ... все этоДоза отображает одну и ту же ячейку в обоих разделах.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2;
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSInteger rows = 0;
switch (section) {
case 0:
rows = 1;
break;
case 1:
rows = 1;
break;
}
return rows;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//Registration Button
static NSString *CellIdentifier = @"CustomRegCell";
static NSString *CellNib = @"LogInCustomCell";
UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:CellNib owner:self options:nil];
cell = (UITableViewCell *)[nib objectAtIndex:0];
}
//Registration Button
static NSString *CellButtonIdentifier = @"CustomSubmitCell";
static NSString *CellButtonNib = @"LogInCustomCell";
UITableViewCell *cellButton = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellButtonIdentifier];
if (cellButton == nil) {
NSArray *nibButton = [[NSBundle mainBundle] loadNibNamed:CellButtonNib owner:self options:nil];
cellButton = (UITableViewCell *)[nibButton objectAtIndex:0];
}
NSLog(@"%i", indexPath.section);
if (indexPath.section == 0) {
return cell; // jumps out of method here
}
if (indexPath.section == 1) {
return cellButton;
}
return nil;
}