indexPath在所有行中返回0

use*_*816 3 objective-c uitableview ios

我创建了一个tableView只有1个部分,它总是返回0 indexPath.Row.我究竟做错了什么?这是我记录的indexPath

NSLog(@"%@",indexPath);

<NSIndexPath: 0xd2897d0> {length = 2, path = 0 - 0}
<NSIndexPath: 0xd290af0> {length = 2, path = 1 - 0}
<NSIndexPath: 0xd2a5cd0> {length = 2, path = 2 - 0}
<NSIndexPath: 0xd2a8340> {length = 2, path = 3 - 0}
Run Code Online (Sandbox Code Playgroud)

的cellForRowAtIndexPath

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



    UITableViewCell *cell = nil;


    if (indexPath.row < 3) {
        TextFieldTableViewCell *accountCell = [tableView dequeueReusableCellWithIdentifier: textFieldCellIdentifier forIndexPath: indexPath];
        accountCell.cellTextField.delegate = self;

            accountCell.cellLabel.text = [accountArray objectAtIndex: indexPath.row];
        if (indexPath.row == 0) {


        accountCell.cellTextField.keyboardType = UIKeyboardTypeDefault;
        } else if (indexPath.row == 1) {


            accountCell.cellTextField.keyboardType = UIKeyboardTypeNumberPad;
        } else if (indexPath.row == 2) {


            accountCell.cellTextField.keyboardType = UIKeyboardTypeNumberPad;
        }

        cell = accountCell;


    } else if (indexPath.row == 3) {

        ACEExpandableTextCell *textViewCell = [tableView expandableTextCellWithId:@"cellId"];
        textViewCell.text = [self.cellData objectAtIndex:indexPath.section];
        textViewCell.textView.placeholder = @"Placeholder";
        cell = textViewCell;

    }


    return cell;
}
Run Code Online (Sandbox Code Playgroud)

Raj*_*esh 12

问题可能是这个

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return [arry count];
}   
 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    return 1;
    }
Run Code Online (Sandbox Code Playgroud)

代替

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

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    return [arry count];
    }
Run Code Online (Sandbox Code Playgroud)