Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.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
Iphone uitableview行渲染异常行为_Iphone_Ios_Ipad_Uitableview - Fatal编程技术网

Iphone uitableview行渲染异常行为

Iphone uitableview行渲染异常行为,iphone,ios,ipad,uitableview,Iphone,Ios,Ipad,Uitableview,我想要两个创建2个分区的uitableview 所以我做了以下代码 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { NSLog(@" I entered numberOfSectionsInTableView"); return 2; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInte

我想要两个创建2个分区的uitableview 所以我做了以下代码

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    NSLog(@" I entered numberOfSectionsInTableView");
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {          
    if (section = 0 ) {  
        1;   
    }
    else {
        9; 
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    NSLog(@" I entered cellForRowAtIndexPath");
    NSLog(@"the Caf files count is : %d",[self.CafFileList count] );
    NSLog(@" the txt file %d",[self.TXTFileList count] );
    if (indexPath.section == 0 ) { // Enter here twice , even I say it contain only one row
        NSLog(@"////////////////////////Section 0 %d" , [indexPath row] );  
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        }   
        [[cell textLabel] setText:[self.TXTFileList objectAtIndex:[indexPath row] ]   ];    
        return cell;    
    }
    else if (indexPath.section == 0 && indexPath.row < [self.TXTFileList count]  ){
        NSLog(@"////////////////////////Section 1 %d" , [indexPath row] );
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        }
        [[cell textLabel] setText:[self.CafFileList objectAtIndex:[indexPath row]]   ];
        return cell;
    }
}

你知道如何解决这个问题吗?

numberOfRowsInSection
中不返回行号,只需输入一个数字,但不返回任何内容

而且

部分
设置为0,您要使用
=
运算符

if (section == 0 ) {  
    return 1;   
}
else {
    return 9; 
}
还有您的代码:

else if (indexPath.section == 0 && indexPath.row < [self.TXTFileList count]  ){
else if(indexPath.section==0&&indexPath.row<[self.TXTFileList count]){

你从来没有为section==1生成过单元格。如果(section=0){?然后是1;:-)你认为如果(section=0){你的
numberofrowsinssection:
函数这样做是什么意思。=运算符是赋值运算符,你应该把它改成==,这是比较运算符
if (section == 0 ) {  
    return 1;   
}
else {
    return 9; 
}
else if (indexPath.section == 0 && indexPath.row < [self.TXTFileList count]  ){