之後,所以這是在C#...TableViewController不填充容器細胞我使用Xamarin的iOS添加
我有一個UITableViewController
動態細胞 - 一個細胞的標題和N多用戶可以添加或刪除。表格視圖下方是一個帶有一對按鈕的頁腳。當添加按鈕被觸摸時,它導航到新項目的編輯器。當它從編輯器返回時,表格視圖突然沒有填充其容器,並且可以看到父視圖的背景顏色(UITableView
的背景爲分組UITableView
樣式的默認ios灰色,父背景爲白色)。
爲了使它更離奇,這並不在iPhone模擬器顯示 - 只有在實際的iPad。
此外,如果再次調用layoutSubviews()
(例如,將方向改爲肖像),它將自行解決。我們在所有地方使用相同的容器和一般設計模式,沒有任何問題。這是第一個顯示問題的視圖。
這裏是代碼看似相關位:
在父視圖包含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...
}
在表格視圖:
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...
}
編輯:實際上,這發生在UINavigationController
上的Push或Pop上,只有當鍵盤打開時。