Ios 重新加载UItableview时,某些零件可见,而某些零件不可见

Ios 重新加载UItableview时,某些零件可见,而某些零件不可见,ios,objective-c,uitableview,ios7,Ios,Objective C,Uitableview,Ios7,当我重新加载TableView时,只有一些数据显示在单元格中,当我触摸时,它显示表格中的所有数据。我使用表视图的内容偏移量作为0,0 你试过什么?cellForRowAtIndexPath和sectionIndexTitlesForTableView的说明是什么?从数据库获取数据并显示数据请发布-cellForRowAtIndexPath的代码在上述步骤之前和之后是否检查了表视图的内容大小?是否如预期的那样?@akashg:添加了上述代码,请检查。 -(NSInteger)numberOfSe

当我重新加载TableView时,只有一些数据显示在单元格中,当我触摸时,它显示表格中的所有数据。我使用表视图的内容偏移量作为0,0


你试过什么?cellForRowAtIndexPath和sectionIndexTitlesForTableView的说明是什么?从数据库获取数据并显示数据请发布-cellForRowAtIndexPath的代码在上述步骤之前和之后是否检查了表视图的内容大小?是否如预期的那样?@akashg:添加了上述代码,请检查。
 -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
            //Searching code
            if (isSearching)
            {
                if ([arrCopyListOfItems count])
                  return [arrIndex count];
                else
                    return 1;
            }
            //filtering code
            else if (isFiltering)
            {
                if ([arrayFilterdContacts count])
                    return [arrIndex count];
                else
                    return 1;
            }
            else
            {
                 if([appDelegate.arrayContactsFromDb count])
                    return [arrIndex count];
                else
                    return 1;
            }

        }


}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
{
            if (isSearching)
            {
                if ([arrCopyListOfItems count])
                {
                    NSString *alphabet = [arrIndex objectAtIndex:section];
                    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"contactName beginswith[c]%@",alphabet];
                    NSArray *sort = [arrCopyListOfItems filteredArrayUsingPredicate:predicate];
                    return [sort  count];
                }
                else
                    return 1;
            }
            else if(isFiltering)
            {
                if ([arrayFilterdContacts count])
                {
                    NSString *alphabet = [arrIndex objectAtIndex:section];
                    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"contactName beginswith[c]%@",alphabet];
                    NSArray *sort = [arrayFilterdContacts filteredArrayUsingPredicate:predicate];
                    return [sort  count];
                }
                else
                    return 1;
            }
            else
            {
                NSString *alphabet = [arrIndex objectAtIndex:section];
                NSPredicate *predicate = [NSPredicate predicateWithFormat:@"contactName beginswith[c]%@",alphabet];
                NSArray *sort = [appDelegate.arrayContactsFromDb filteredArrayUsingPredicate:predicate];
                return [sort  count];
            }

}

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
    UITableViewCell *cell = [[UITableViewCell alloc] init];
    cell.textLabel.backgroundColor=[UIColor clearColor];
    cell.textLabel.font = [UIFont systemFontOfSize:14];
    cell.backgroundColor = [UIColor clearColor];
    Contacts *objContact;
            //Changing colors
            if (indexPath.row % 2 == 0)
            {
                cell.contentView.backgroundColor = [UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0];
            }
            else
            {
                cell.contentView.backgroundColor = [UIColor colorWithRed:232.0/255.0 green:232.0/255.0 blue:232.0/255.0 alpha:1.0];
            }

            UILongPressGestureRecognizer *longPressGesture =
            [[UILongPressGestureRecognizer alloc]
             initWithTarget:self action:@selector(longPress:)] ;

            [cell addGestureRecognizer:longPressGesture];
            //Local Searching Table View
            if (isSearching)
            {                
                if([arrCopyListOfItems count])
                {
                    NSString *alphabet = [arrIndex objectAtIndex:[indexPath section]];
                    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"contactName beginswith[c]%@",alphabet];
                    NSArray *arysortContact = [arrCopyListOfItems filteredArrayUsingPredicate:predicate];
                    objContact = [arysortContact objectAtIndex:indexPath.row];
                }
                else
                {
                    cell.textLabel.text = kNoSearchResult;
                    cell.textLabel.textAlignment = NSTextAlignmentCenter;
                    return cell;
                }
            }
            //Contacts Table View WithOut Searching and showing filtering
            else
            {
                cell.textLabel.frame = CGRectMake(2, 3, 35, 30);
                //Showing filtering list
                if (isFiltering)
                {
                    if ([arrayFilterdContacts count])
                    {
                        NSString *alphabet = [arrIndex objectAtIndex:[indexPath section]];
                        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"contactName beginswith[c]%@",alphabet];
                        NSArray *arysortContact = [arrayFilterdContacts filteredArrayUsingPredicate:predicate];
                        objContact = [arysortContact objectAtIndex:indexPath.row];
                    }
                    else
                    {
                        cell.textLabel.text = kContactFilter;
                        cell.textLabel.textAlignment = NSTextAlignmentCenter;
                        return cell;
                    }
                }
                //Showing all the contacts list
                else
                {
                    NSString *alphabet = [arrIndex objectAtIndex:[indexPath section]];
                    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"contactName beginswith[c]%@",alphabet];
                    NSArray *arysortContact = [appDelegate.arrayContactsFromDb filteredArrayUsingPredicate:predicate];
                    if ([arysortContact count])
                    {
                        objContact = [arysortContact objectAtIndex:indexPath.row];
                    }
                }
             }

            //Displaying name of a contact
            UILabel *lblName;
            if([objContact.contactName length ]> 0)
            {
                lblName = [self createLabelWithTitle:[NSString stringWithFormat:@"%@ %@",objContact.contactName,objContact.lastName] frame:CGRectMake(15, 0, 150, 60) tag:10 font:fontMyriad color:[UIColor colorWithRed:40.0/255.0 green:40.0/255.0 blue:40.0/255.0 alpha:1] numberOfLines:1];
            }
            else
            {
                lblName = [self createLabelWithTitle:objContact.phoneNumber frame:CGRectMake(15, 0, 150, 60) tag:10 font:fontMyriad color:[UIColor colorWithRed:40.0/255.0 green:40.0/255.0 blue:40.0/255.0 alpha:1] numberOfLines:1];
            }

            lblName.backgroundColor=[UIColor clearColor];
            lblName.textAlignment = NSTextAlignmentLeft;
            lblName.numberOfLines=10000;
            lblName.lineBreakMode=NSLineBreakByWordWrapping;

            //Showing different color for users
            if ([objContact.Id integerValue] != 0 || objContact.businessInfo)
            {
                lblName.textColor = [UIColor blueColor];
            }
            [cell.contentView addSubview:lblName];

            //Displaying all tags for a contact
            NSMutableArray *arrTags = [(NSMutableArray*)[objContact.contactsToTagMaster allObjects] mutableCopy];
            NSSortDescriptor *valueDescriptor = [[NSSortDescriptor alloc] initWithKey:@"tagName" ascending:YES];
            NSArray * descriptors = [NSArray arrayWithObject:valueDescriptor];

            arrTags = (NSMutableArray*)[arrTags sortedArrayUsingDescriptors:descriptors];

            float floatTagsHeight= [self getTagNameHeight:arrTags];

            if ([arrTags count]>2) {

                lblName.frame=CGRectMake(10, 0, 150, floatTagsHeight+[arrTags count]*2+4);
            }


            UIScrollView   *scrollVwForImage=[[UIScrollView alloc]initWithFrame:CGRectMake(200, 2, 80, floatTagsHeight+[arrTags count]*2+10)];
            scrollVwForImage.backgroundColor =[UIColor clearColor];

            if (isOpened) {
                if ([arrTags count]>2)
                lblName.frame=CGRectMake(lblName.frame.origin.x, lblName.frame.origin.y, 115, floatTagsHeight+[arrTags count]*2+4);
                float floatTagsHeight= [self getTagNameHeight:arrTags];

                scrollVwForImage.frame=CGRectMake(130, 2, 80, floatTagsHeight+[arrTags count]*2+10);
            }

            if(objContact.contactsToTagMaster != nil)
            {
                int intHeight=2;
                for(int i=0;i< [arrTags count];i++)
                {
                    //If Tag short name is present
                    if([[[arrTags objectAtIndex:i]valueForKey:@"tagName"] length])
                    {
                        CGSize size= [[[arrTags objectAtIndex:i]valueForKey:@"tagName"] sizeWithFont:fontMyriad constrainedToSize:CGSizeMake(70, 1000) lineBreakMode:NSLineBreakByWordWrapping];
                        float floatTagHeight=(size.height>15)?size.height:15;


                        UIImageView *imageViewBox = [[UIImageView alloc] initWithFrame:CGRectMake(0, intHeight, 80, floatTagHeight)];
                        imageViewBox.backgroundColor=[UIColor colorWithRed:211.0/255.0 green:211.0/255.0 blue:211.0/255.0 alpha:1.0];
                        [scrollVwForImage addSubview:imageViewBox];


                        UILabel *lblTagShortName = [[UILabel alloc]initWithFrame:CGRectMake(5, 0, 75, floatTagHeight)];
                        lblTagShortName.backgroundColor = [UIColor clearColor];
                        lblTagShortName.text = [[arrTags objectAtIndex:i]valueForKey:@"tagName"];
                        [lblTagShortName setFont:fontMyriad];
                        lblTagShortName.textColor = [UIColor colorWithRed:125.0/255.0 green:129.0/255.0 blue:135.0/255.0 alpha:1] ;
                        lblTagShortName.autoresizesSubviews = YES;
                        lblTagShortName.textAlignment = NSTextAlignmentLeft;
                        lblTagShortName.lineBreakMode=NSLineBreakByWordWrapping;
                        lblTagShortName.numberOfLines=1000;
                        //lblTagShortName.adjustsFontSizeToFitWidth=YES;
                        [imageViewBox addSubview:lblTagShortName];

                        intHeight+=floatTagHeight+2;

                    }
                }
            }


            [cell.contentView addSubview:scrollVwForImage];
        }

    return cell;
}