0
我有一個很長的屏幕(很多字段)。在XCode的結構:Xamarin和XCode:調整UIView和UITableView的大小
View
ScrollView
View
View
.
.
.
TableContainer (View)
TableView
TableContainer和的TableView具有高度。 當我在頁面上 - 我設置高度TableView高度根據項數和增加TableView根據項目數量。 所有作品都可以。 但是,當我旋轉設備 - TableView消失(高度重置爲)。
類:
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);
}
}
}
我在新的iOS和我知道我的結構是不好的。 請教,如何重新加載TableView and ScrollView。 請幫助我。
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator NS_AVAILABLE_IOS(8_0);
它在Xcode與Objective-C的像這樣實現:
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
// Code here will execute before the rotation begins.
// Equivalent to placing it in the deprecated method -[willRotateToInterfaceOrientation:duration:].
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
// Place code here to perform animations during the rotation.
// You can pass nil for this closure if not necessary.
// Reorganize views, or move child view controllers.
if (UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
//Update UI
}
if (UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation)) {
//Update UI
}
}completion:^(id<UIViewControllerTransitionCoordinatorContext> context){
// Code here will execute after the rotation has finished.
// Equivalent to placing it in the deprecated method -[didRotateFromInterfaceOrientation:].
// Do any cleanup, if necessary.
}];
}
它也可以發現
謝謝@凱文,它適合我! 請問您是否可以幫我解決其他問題: 1. https://stackoverflow.com/questions/46224467/mvvmcross-hamburger-menu-for-ios 2. https://stackoverflow.com/questions/46202789/mvvmcross-platform-exceptions-mvxexception-could-load-plugin-assembly-for-t 謝謝。 – DaleYY