iOS 7.1 UitableviewCell content overlaps with ones below

前端 未结 7 1773
执念已碎
执念已碎 2020-12-08 07:11

So I have code, which is sucessfully working on iOS 7.0 but not in 7.1. I have a simple tableview, with code:

- (NSInteger)numberOfSectionsInTableView:(UITab         


        
相关标签:
7条回答
  • 2020-12-08 07:37

    Are you using storyboards? If so, select the table view controller in storyboards and uncheck the "Under bottom bars" You can also do this programmatically.

    If your TVC inherits from a nav view controller or a tab view controller, you may need to uncheck this layout option on the parent view instead

    0 讨论(0)
  • 2020-12-08 07:39

    Here is the Perfect solution of Overlapping content in Cells.

    Just use below code in cellForRowAtIndexPath after allocating cell and before adding subviews.

    for (id object in cell.contentView.subviews)
    {
        [object removeFromSuperview];
    }  
    

    Actually the overlapping is occurring because whenever you scroll the tableview its allocating your added view again and again. So above code will solve your problem by removing the existing views from cell's contentView.

    Now You can see the memory debug session after applying above code, your memory is stable this time.

    Hope it'll help you.

    Thanks !

    0 讨论(0)
  • 2020-12-08 07:48

    This is problem with recreating cell contents. Try with following code segment.

    for(UIView *view in cell.contentView.subviews){  
            if ([view isKindOfClass:[UIView class]]) {  
                [view removeFromSuperview];   
            }
        }
    
    0 讨论(0)
  • 2020-12-08 07:48

    had similar behavior in iOS 8, using storyboard / IB.

    fix was to add a Bottom Space to: Superview constraint from the bottom-most view to bottom of the prototype cell's Content View. The other views and constraints were all anchored from the top.

    0 讨论(0)
  • 2020-12-08 07:50

    @Gaurav your answer should be the accepted answer. Thanks!

    for object in cell.contentView.subviews
                {
                    object.removeFromSuperview();
                }
    
    0 讨论(0)
  • 2020-12-08 08:00

    Re-checking all 4 constraints helps. While working with table view or collection view it's necessary to apply all four constraints (leading, trailing, top, bottom.)

    0 讨论(0)
提交回复
热议问题