简体   繁体   English

滚动时UITableView被切断了吗?

[英]UITableView cut off when scrolling?

I just realized that if I use this code to round only the top 2 edges of my UITableView : 我刚刚意识到,如果我使用这段代码只围绕我的UITableView的前2个边缘:

UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:thetableView.bounds 
                                                   byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
                                                         cornerRadii:CGSizeMake(10.0, 10.0)];
    // Create the shape layer and set its path
    CAShapeLayer *maskLayer = [CAShapeLayer layer];
    maskLayer.frame = thetableView.bounds;
    maskLayer.path = maskPath.CGPath;
    thetableView.layer.mask = maskLayer;

My tableview content will get cut off if I scroll down to anything that was below the frame of the UITableView that I made in Interface Builder. 如果我向下滚动到我在Interface Builder中创建的UITableView框架下面的任何内容,我的tableview内容将被切断。 Although if I take this code out, everything is fine. 虽然如果我把这个代码拿出来,一切都很好。

Is there a way to get the best of both worlds where I can round the top corners and the content below the original frame doesn't get cut off? 有没有办法充分利用两个世界的优势,我可以围绕顶角,原始框架下面的内容不会被切断?

Thanks! 谢谢!

Here is the solution. 这是解决方案。 Enclose your table view in an outer UIView (exactly the same size as the table view, and with the table view at 0,0 in the enclosing view). 将表视图包含在外部UIView中(与表视图完全相同,并且在封闭视图中将表视图设置为0,0)。 Then hook up an outlet to that enclosing view and set rounded top corners on it. 然后将插座连接到该封闭视图并在其上设置圆角顶角。

I think this is a bug on Apple's part. 我认为这是Apple的一个错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM