Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITableView未呈现所有部分_Ios_Objective C_Uitableview - Fatal编程技术网

Ios UITableView未呈现所有部分

Ios UITableView未呈现所有部分,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我有一个UIViewController,里面有一个UITableView。UITableView有3个部分,如下所示 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 3; } 我的细胞是这样设置的 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath

我有一个UIViewController,里面有一个UITableView。UITableView有3个部分,如下所示

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;
}
我的细胞是这样设置的

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

    static NSString *CellIdentifier        = @"ContactInfoCellIdentifier";

    NSUInteger section = [indexPath section];

    UITableViewCell *cell;

    switch (section)
    {
        case 0:
        {

            ...

            break;
        }
        case 1:
        {

            ...    
            break;
        }
        case 2:
        {

            ...

            break;
        }
        default:
            break;
    }

    return cell;
}

但由于某种原因,案例2第3节从未被调用。你知道为什么会这样吗?

你需要像这样实例化UITableViewCell
UITableViewCell*cell=[tableView dequeueReusableCellWithIdentifier:“YourIdentifier”]

对于
numberOfRowsInSection
返回什么?它返回数组中的计数,如果数组为空,则返回1,因此每个节应始终至少有1行