iOS 8 TableView overlaps rows after scrolling

2019-08-08 13:41发布

问题:

Only on iOS 8 and when scrolling do my rows overlap each other. I tried the fixes for similar topics related to iOS 7 but I haven't solved my issue. Please see attached image and my UITableView GetCell method. I'm using MonoTouch but the logic is the same as objective-c.

public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
        {
            UITableViewCell cell = null;
            cell = tableView.DequeueReusableCell(CELL);

            if (cell == null)
                cell = new UITableViewCell(UITableViewCellStyle.Default, CELL);

            if (cell.ContentView.Subviews.Length > 0)
                cell.ContentView.Subviews[0].RemoveFromSuperview();

            UIView backgroundView = new UIView();
            cell.SelectedBackgroundView = backgroundView;

            if (list[indexPath.Row] != null)
            {
                cell.ContentView.AddSubview(list[indexPath.Row].View);
            }
            return cell;
        }

回答1:

That might be one of the many senseless bugs from building on Xcode 6. Try this on the viewDidLoad function:

YourTableView.rowHeight = ##; //write your desired height. 

if this doesn't work also try implementing the heightForRowAtIndexPath function for your tableview:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return ##; //write your desired height
}