为什么我的UITableViewCell有一个空白区域?

时间:2017-05-31 03:10:33

标签: objective-c uitableview

enter image description here

enter image description here

大家好,我需要一些帮助来解决问题 我不知道为什么我的UITableViewCell中有一个空白区域,如图所示 当我继续放下桌子时,蓝色UITextView将消失,然后出现下一个单元格。任何人都知道为什么?

    @implementation TableCellModel 
+(UITableViewCell *) getCellOfFreeChampionsList
{
    UITableViewCell * tableCell = [[super alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NULL];
    UITextView * textView = [[UITextView alloc] init];
    textView.tag = 11;
    textView.text = @"1qaz2wsxE";
    textView.frame = CGRectMake(5, 5, 70, 20);
    textView.backgroundColor = [UIColor blueColor];
    [tableCell.contentView addSubview:textView];

//    UILabel * la = [[UILabel alloc] init];
//    la.frame = CGRectMake(5, 50, 70, 20);
//    la.tag = 12;
//    [tableCell.contentView addSubview:la];

    NSLog(@"%@", textView.text);
    NSLog(@"count is %lu", (unsigned long)tableCell.subviews.count);

    return tableCell;
}


    @implementation TableViewDataSource

@synthesize tableView;
@synthesize tableCell;
@synthesize LHfetchedResultsController;
@synthesize numberOfRows;
@synthesize dataTemp;
@synthesize paused;

-(id)initWithTableView:(UITableView *) tableView
{
    self = [super init];
    if (self) {
        self.tableView = tableView;
        self.tableView.dataSource = self;
        self.tableView.delegate = self;
    }
    return self;
}



-(void)dateSourceWithChineseNewestVideos:(NSArray *)videosResults
{
    self.dataTemp = videosResults;
    self.tableCell = [TableCellModel getCellOfFreeChampionsList];
    self.numberOfRows = videosResults.count;
    NSInteger n = self.numberOfRows;
    if (self.numberOfRows == 0) {
        self.numberOfRows = 1;
    }
}

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




//    [self configCellData:indexPath cell:self.tableCell];
    if (self.dataTemp.count < 0) {
        NSArray * arr = self.dataTemp;
        NSInteger n = arr.count;
        NSInteger indexNum = indexPath.row;
        ChineseNewestVideos * re1 = [self.dataTemp objectAtIndex:indexNum];
        UITextView * textView = [tableCell viewWithTag:11];
        textView.text = re1.title;


        NSLog(@"text is %lu",(unsigned long)tableCell.subviews.count);
        NSLog(@"text is %@",textView.text);

//        UILabel * la = [tableCell viewWithTag:12];
//        la.text = [NSString stringWithFormat:@"%lD",(long)n];
    }


    return self.tableCell;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
//    id<NSFetchedResultsSectionInfo> sectionInfo = self.LHfetchedResultsController.sections[section];
//    self.numberOfRows = sectionInfo.numberOfObjects;
    return self.numberOfRows;
}

2 个答案:

答案 0 :(得分:0)

以编程方式:

// Objective-C
self.automaticallyAdjustsScrollViewInsets = NO;


// Swift
self.automaticallyAdjustsScrollViewInsets = false

使用Storyboard:

enter image description here

答案 1 :(得分:0)

因为我在UITableViewCell之后将cellForRowAtIndexPath声明为git.exe daemon ...移动后