Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/93.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.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 UITable查看表中的行数部分查看行的高度索引路径提供错误访问_Ios_Objective C_Uitableview_Exc Bad Access - Fatal编程技术网

iOS UITable查看表中的行数部分查看行的高度索引路径提供错误访问

iOS UITable查看表中的行数部分查看行的高度索引路径提供错误访问,ios,objective-c,uitableview,exc-bad-access,Ios,Objective C,Uitableview,Exc Bad Access,我在下面输入if语句时收到EXC错误访问错误[tableView numberOfRowsInSection:0]。我正在计算UITableView在heightForRowAtIndexPath内的tableView numberOfRowsInSection 我有以下代码来设置第一节最后一行的高度 -(CGFloat )tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

我在下面输入if语句时收到EXC错误访问错误
[tableView numberOfRowsInSection:0]
。我正在计算UITableView在heightForRowAtIndexPath内的
tableView numberOfRowsInSection

我有以下代码来设置第一节最后一行的高度

-(CGFloat )tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

        if (indexPath.section==0) {
            NSInteger lastRowIndex = [tableView numberOfRowsInSection:0] - 1;

            if (indexPath.row==lastRowIndex) {
                return 44.0f;

            }else{
                return 100;

            }

        }else{

            return 100;
        }


}
我得到的错误如下图所示

我觉得这个方法不合适


将代码更新为以下内容

-(CGFloat )tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

        if (indexPath.section==0) {
            NSInteger lastRowIndex = [self numberOfRowsInSection:indexPath.section] - 1;

            if (indexPath.row==lastRowIndex) {
                return 44.0f;

            }else{
                return 100;

            }

        }else{

            return 100;
        }
}

将代码更新为以下内容

-(CGFloat )tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

        if (indexPath.section==0) {
            NSInteger lastRowIndex = [self numberOfRowsInSection:indexPath.section] - 1;

            if (indexPath.row==lastRowIndex) {
                return 44.0f;

            }else{
                return 100;

            }

        }else{

            return 100;
        }
}
请尝试以下代码:

-(CGFloat )tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

        if (indexPath.section==0) {
            long lastRowIndex = [self.yourArray count]-1;

            // other wise use this line
           // long lastRowIndex = [self.yourArray lastObject]-1;

            if (indexPath.row==lastRowIndex) {
                return 44.0f;

            }else{
                return 100;

            }

        }else{

            return 100;
        }
}
因为此
numberOfRowsInSection
不起作用
heightForRowAtIndexPath
delegate方法。

请尝试以下代码:

-(CGFloat )tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

        if (indexPath.section==0) {
            long lastRowIndex = [self.yourArray count]-1;

            // other wise use this line
           // long lastRowIndex = [self.yourArray lastObject]-1;

            if (indexPath.row==lastRowIndex) {
                return 44.0f;

            }else{
                return 100;

            }

        }else{

            return 100;
        }
}
因为此
numberOfRowsInSection
不起作用
heightForRowAtIndexPath
delegate方法。

请尝试使用此方法。 使一个全局NSinteger firstSectionCount; 然后试试这个

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if (section==0){
    firstSectionCount = [ storeArr count];
    return [ storeArr count]+1;
}else{
    return [ [[itemArr objectAtIndex:section-1]   objectForKey:@"itemList"]count];
}
然后

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section==0) {
    if (indexPath.row==firstSectionCount) {
        return 44.0f;

    }else{
        return 100;

    }
}
else{
      return 100;  
}
希望这能帮助您……

请尝试一下。 使一个全局NSinteger firstSectionCount; 然后试试这个

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if (section==0){
    firstSectionCount = [ storeArr count];
    return [ storeArr count]+1;
}else{
    return [ [[itemArr objectAtIndex:section-1]   objectForKey:@"itemList"]count];
}
然后

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section==0) {
    if (indexPath.row==firstSectionCount) {
        return 44.0f;

    }else{
        return 100;

    }
}
else{
      return 100;  
}
希望这能帮助你……

试试这个

 -(CGFloat )tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    if (indexPath.section==0) {
        NSInteger lastRowIndex = yourArray.count - 1; 

        if (indexPath.row==lastRowIndex) {
            return 44.0f;

        }else{
            return 100;

        }

    }else{

        return 100;
    }
}
试试这个

 -(CGFloat )tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    if (indexPath.section==0) {
        NSInteger lastRowIndex = yourArray.count - 1; 

        if (indexPath.row==lastRowIndex) {
            return 44.0f;

        }else{
            return 100;

        }

    }else{

        return 100;
    }
}
试试这个方法
[self tableView:tableView numberofrowsinssection:0]
而不是
[tableView numberofrowssection:0]
。它很好用。

试试这个方法
[self tableView:tableView numberofrowsinssection:0]
而不是
[tableView numberofrowssection:0]
。它工作得很好。

我们能不能使用像tableView numberOfRowsInSection这样的东西,该方法比array Count工作得更好。
numberOfRowsInSection
方法中有什么?我认为不是
[tableView numberOfRowsInSection:0]-1
您可以使用
[self myNumberOfRowsMethod]-1我不想使用myNumberOfRowsMethod我想使用一些更好的方法,所以你可以发布你的-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section方法的代码?-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section{如果(section==0){返回[storeArr count]+1;}否则{return[[[itemArr objectAtIndex:section-1]objectForKey:@“itemList”]count];}我们不能使用一些东西,比如tableView numberofrowsinssection,该方法比array count工作得更好吗
numberofrowsinssection
方法中有什么?我想用
[tableView numberOfRowsInSection:0]-1;
您可以使用
[self myNumberOfRowsMethod]-1;
我不想使用myNumberOfRowsMethod,我想使用一些更好的方法,所以您可以发布您的-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section方法的代码-(NSInteger)tableView:(UITableView*))tableView numberOfRowsInSection:(NSInteger)节{if(section==0){return[storeArr count]+1;}否则{return[[itemArr objectAtIndex:section-1]objectForKey:@“itemList”]count];}你的答案与问题的差异是什么,已验证的条件与0相等\n你能检查这个问题你的答案与问题的差异是什么,已验证的条件与0相等\n你能检查这个问题吗?我会试试那个兄弟并回答你可以检查这个问题吗d将回答ucan u检查这个问题你可以检查这个问题我可以得到太多的brocan u检查这个问题我可以得到太多的brocan u检查这个问题你可以检查这个问题你可以检查这个问题你可以检查这个问题吗