UITableVIew行仅在滚动时可见

时间:2014-08-21 07:52:53

标签: ios objective-c uitableview

我有一个tableView,我用数组填充。最初只有第一行是可见的,当它被拉起时,下面的行逐个出现。

当我向下拉回到顶部时,底部的行开始一个接一个地消失。我不明白发生了什么。

enter image description here

修改

这里是cellForRowAtIndexPath代码

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
        UITableViewCell *cell;
        if(tabIndex==2){
            if([dataDictionary valueForKey:@"myFriends"]){
                cell=[tableView dequeueReusableCellWithIdentifier:@"myCircle" forIndexPath:indexPath];
                NSArray *array = [dataDictionary valueForKey:@"myFriends"];
                UIImageView *profileImage = (UIImageView*)[cell viewWithTag:1];
                CALayer *imageLayer = profileImage.layer;
                [imageLayer setCornerRadius:25];
                [imageLayer setBorderWidth:0.6];
                [imageLayer setBorderColor:[UIColor orangeColor].CGColor];
                [imageLayer setMasksToBounds:YES];
                UILabel *uname = (UILabel*)[cell viewWithTag:2];
                UILabel *description = (UILabel*)[cell viewWithTag:3];
                [profileImage setImage:[UIImage imageNamed:@""]];
                uname.text = [[array objectAtIndex:[indexPath row]] valueForKey:@"name"];
                description.text = [[array objectAtIndex:[indexPath row]] valueForKey:@"description"];
            }else
                cell=[tableView dequeueReusableCellWithIdentifier:@"EmptyCell" forIndexPath:indexPath];
        }
        if(tabIndex==3){

        }
        .
        .
        .
    }

1 个答案:

答案 0 :(得分:0)

对,经过详细检查后,最终发现了错误。

enter image description here

如果你在第1张图片中看到自动调整应用于拉伸和定位,它似乎没有反映在左边的视图上,但在运行时它确实显示出不稳定的行为。改变了第二张图片,一切都运行正常。

enter image description here

您也可以尝试clipSubviews

相关问题