UITableView horizontal cell separator lines don't scroll up or down
I have written some MonoTouch code to display a Nib'less UITableView and the view looks ok populated with cell data on initial display. However when I touch scroll down to view more data I end up with a double grid patten comprising of static horizontal cell separator lines that don't move with the scroll action plus another set or horizontal cell separator lines that are correctly spaced and which move with the scroll down action.
After scrolling back up to the top of the table view, the static and dynamic horizontals sync up perfectly and the screen looks normal. Further scrolling recreates the problem.
I am using default UITableViewCell objects to populate the table rows.
I have probably failed to configure something that Interface Builder would normal do. Any ideas? Hopefully the Objective-C folks will be able to interpret the .Net code.
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
_tableView = new UITableView()
{
Source = new TableSource(),
AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth,
BackgroundColor = UIColor.White
};
_tableView.SizeToFit();
_tableView.Frame = new RectangleF ( 0, 0, this.View.Frame.Width, this.View.Frame.Height );
this.View.AddSubview( _tableView );
Update 1: I was concerned the extra set of horizontal cell separator lines were bleeding through from the previous view rendered in the navigation controller stack. So I re-ordered the app to make the problematic table the first view displayed on app start-up but the problem remained.
Update 2: Added
tableView.SeparatorStyle = UITableViewCellSeparatorStyle.None;
This avoids the double set of horizontal lines but I am still left 开发者_开发百科with the static horizontals that intersect through the middle of cells as the table view scrolls.
Update 3: Have a vague theory this is something to do with a cell height configuration mismatch or background fill issue and so the horizontal lines might represent unpainted pixels in the table view. I am not sure how to test this theory?
Solution found. The code example above had been adopted from a 3rd party MonoTouch sample application in the blogshere. That code seems to be creating two fully overlapped UITableViews and the static grid lines were probably from the empty and deeper UITableView in the z-order that did not respond to any touch scroll gestures.
There is no need to manually instantiate a UITableView object as shown above because the UITableViewController class does this for us, so the AddSubview() call is superfluous.
Here is the code that works for me:
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
this.TableView.Source = new TableSource();
}
精彩评论