Reputation: 158
I'm using Xamarin iOS, so this is in C#...
I have a UITableViewController
with dynamic cells -- one for a Title and N number of cells which the user can add or remove. Below the table view is a footer with a couple buttons. When the Add button is touched, it navigates to an editor for the new item. When it returns from the editor, suddenly the table view isn't filling its container, and the background color of the parent view is seen (Background of the UITableView
is default ios grey for Grouped UITableView
style. Parent background is white).
To make it even more bizarre, this doesn't show up in the iOS simulator -- only on an actual iPad.
Furthermore, it resolves itself if layoutSubviews()
is called again (e.g. change orientation to portrait). We use the same container and general design pattern all over the place with no problems. This is the first View that has shown a problem.
Here are the seemingly relevant bits of code:
In the parent view that contains the UITableView
:
public override void ViewDidLoad()
{
base.ViewDidLoad();
_propertyView = new BackNotifyingUINavigationController(this); //This navigation controller hosts the table view
AddChildViewController(_propertyView);
_propertyView.View.Frame = PropertyContainer.Bounds;
PropertyContainer.Add(_propertyView.View);
_propertyView.DidMoveToParentViewController(this);
_propertyView.View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
//Some unrelated views...
//Some MvvmCross binding stuff...
}
In the table view:
public override void ViewDidLoad()
{
base.ViewDidLoad();
_tableSource = new TableSource(TableView); //Custom MvxTableViewSource. Seemingly not overriding anything relevant
_tableSource.UseAnimations = true;
_tableSource.DeselectAutomatically = true;
_tableSource.ReloadOnAllItemsSourceSets = true;
TableView.AlwaysBounceVertical = false;
TableView.TableHeaderView = new UIView(new CoreGraphics.CGRect(0, 0, TableView.Bounds.Width, 10.0f));
TableView.Source = _tableSource;
TableView.SetEditing(true, false); //Always in editing mode
_doneButton = new UIBarButtonItem(UIBarButtonSystemItem.Done);
NavigationItem.RightBarButtonItem = _doneButton;
//Some MvvmCross binding stuff...
}
Edit: This actually happens on both a Push or a Pop on the UINavigationController
, only when the keyboard is open.
Upvotes: 1
Views: 148
Reputation: 158
Finally found a workaround that seems to do the trick, but it feels like a big hack.
In the view controller that owns the UINavigationController...
public override void ViewDidLayoutSubviews()
{
base.ViewDidLayoutSubviews();
if (_propertyView.TopViewController != null)
{
_propertyView.TopViewController.View.Frame = _propertyView.View.Frame;
}
}
Of course this is only appropriate if you want the ViewController to take up the UINavigationController's full frame.
Seems like there should be a better way to handle this...
Upvotes: 0