/// <summary> /// Dispose the specified disposing. /// </summary> /// <returns>The dispose.</returns> /// <param name="disposing">If set to <c>true</c> disposing.</param> protected override void Dispose(bool disposing) { _parentPage.Appearing -= ParentPageAppearing; if (_disposed) { return; } if (disposing) { _contentSizeObserver.Dispose(); _contentSizeObserver = null; Element.CollectionChanged -= OnCollectionChanged; Element.SectionCollectionChanged -= OnSectionCollectionChanged; Element.SectionPropertyChanged -= OnSectionPropertyChanged; _insetTracker?.Dispose(); _insetTracker = null; foreach (UIView subview in Subviews) { DisposeSubviews(subview); } _tableview = null; } _disposed = true; base.Dispose(disposing); }
/// <summary> /// Ons the element changed. /// </summary> /// <param name="e">E.</param> protected override void OnElementChanged(ElementChangedEventArgs <Shared.sv.SettingsView> e) { base.OnElementChanged(e); if (e.OldElement != null) { e.OldElement.CollectionChanged -= OnCollectionChanged; e.OldElement.SectionCollectionChanged -= OnSectionCollectionChanged; e.OldElement.SectionPropertyChanged -= OnSectionPropertyChanged; } if (e.NewElement != null) { _tableview = new UITableView(CGRect.Empty, UITableViewStyle.Grouped); if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0)) { _tableview.DragDelegate = this; _tableview.DropDelegate = this; _tableview.DragInteractionEnabled = true; _tableview.Source = new SettingsTableSource(Element); } else { _tableview.Editing = true; _tableview.AllowsSelectionDuringEditing = true; // When Editing is true, for some reason, UITableView top margin is displayed. // force removing the margin by the following code. _topInset = 36; _tableview.ContentInset = new UIEdgeInsets(-_topInset, 0, 0, 0); _tableview.Source = new SettingsLagacyTableSource(Element); } SetNativeControl(_tableview); _tableview.ScrollEnabled = true; _tableview.RowHeight = UITableView.AutomaticDimension; _tableview.KeyboardDismissMode = UIScrollViewKeyboardDismissMode.OnDrag; _tableview.CellLayoutMarginsFollowReadableWidth = false; _tableview.SectionHeaderHeight = UITableView.AutomaticDimension; _tableview.EstimatedSectionHeaderHeight = UITableView.AutomaticDimension; _tableview.SectionFooterHeight = UITableView.AutomaticDimension; _tableview.EstimatedSectionFooterHeight = UITableView.AutomaticDimension; _tableview.RegisterClassForHeaderFooterViewReuse(typeof(TextHeaderView), TextHeaderId); _tableview.RegisterClassForHeaderFooterViewReuse(typeof(TextFooterView), TextFooterId); _tableview.RegisterClassForHeaderFooterViewReuse(typeof(CustomHeaderView), CustomHeaderId); _tableview.RegisterClassForHeaderFooterViewReuse(typeof(CustomFooterView), CustomFooterId); e.NewElement.CollectionChanged += OnCollectionChanged; e.NewElement.SectionCollectionChanged += OnSectionCollectionChanged; e.NewElement.SectionPropertyChanged += OnSectionPropertyChanged; UpdateBackgroundColor(); UpdateSeparator(); UpdateRowHeight(); Element elm = Element; while (elm != null) { elm = elm.Parent; if (elm is Page) { break; } } _parentPage = elm as Page; _parentPage.Appearing += ParentPageAppearing; _insetTracker = new KeyboardInsetTracker(_tableview, () => Control.Window, insets => Control.ContentInset = Control.ScrollIndicatorInsets = insets, point => { CGPoint offset = Control.ContentOffset; offset.Y += point.Y; Control.SetContentOffset(offset, true); } ); _contentSizeObserver = _tableview.AddObserver("contentSize", NSKeyValueObservingOptions.New, OnContentSizeChanged); } }