I have a very long screen (a lot of fields). Structure in XCode:
View
ScrollView
View
View
.
.
.
TableContainer (View)
TableView
TableContainer and TableView have height 0. When I go on page - I set height of TableView height according to items count and increase TableView according to items count. All works OK. But, when I rotate device - TableView disappears (height resets to 0).
Class:
public partial class TrackingView: BaseView<TrackingViewModel>
{
public TrackingView() : base("TrackingView")
{
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
var source = new RetrieveShipmentDetailsViewSource(PortsTable, ShipmentDetailsCell.Key, ShipmentDetailsCell.Key);
PortsTable.Source = source;
var set = this.CreateBindingSet<TrackingModel, TrackingViewModel>();
set.Bind(ShipmentLabel).To(vm => vm.ShipmentNumber);
set.Bind(CustCodeLabel).To(vm => vm.Shipment.CustomerCode);
set.Bind(CustNameLabel).To(vm => vm.Shipment.CustomerName);
);
ViewModel.ShipmentLoadedSuccess += (sender, e) =>
{
InvokeOnMainThread(delegate
{
PortsTable.ReloadData();
UpdateView();
});
};
PortsTable.SeparatorStyle = UITableViewCellSeparatorStyle.None;
PortsTable.ReloadData();
set.Apply();
}
private void UpdateView()
{
if (ViewModel.Shipment != null && ViewModel.Shipment.VesselPorts != null)
{
PortsTable.ContentSize = new CGSize(MainView.ContentSize.Width, (ViewModel.Shipment.VesselPorts.Count * 200) + 55);
PortsTable.Frame = new CGRect(PortsTable.Frame.X, PortsTable.Frame.Y, PortsTable.Frame.Size.Width,
(ViewModel.Shipment.VesselPorts.Count * 200) + 55);
MainView.ContentSize = new CGSize(MainView.ContentSize.Width,
MainView.ContentSize.Height + (ViewModel.Shipment.VesselPorts.Count * 200) + 55);
}
}
}
I'm new in iOS and I know that my structure isn't good. Advice, please, how to reload TableView and ScrollView. Help me, please.