public override void ViewDidLoad() { base.ViewDidLoad(); this.View.BackgroundColor = UIColor.White; table = new UITableView(); table.Frame = new CoreGraphics.CGRect(0, 40, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height - 64 - 40); table.DataSource = new TableDataSource(this); table.Delegate = new TableDelegate(this); this.View.AddSubview(table); MJRefreshNormalHeader header = new MJRefreshNormalHeader(); table.SetHeader(header); MJRefreshAutoNormalFooter footer = new MJRefreshAutoNormalFooter(); table.SetFooter(footer); header.RefreshingBlock = async() => { await Task.Delay(2000); InvokeOnMainThread(() => { footer.Hidden = true; this.Count += 12; table.ReloadData(); table.Header().EndRefreshing(); footer.Hidden = false; }); }; header.SetTitle(NSBundle_MJRefresh.Mj_localizedStringForKey(NSBundle_MJRefresh.Mj_refreshBundle(NSBundle.MainBundle), "MJRefreshHeaderIdleText"), MJRefreshState.Idle); header.SetTitle(NSBundle_MJRefresh.Mj_localizedStringForKey(NSBundle_MJRefresh.Mj_refreshBundle(NSBundle.MainBundle), "MJRefreshHeaderPullingText"), MJRefreshState.Pulling); header.SetTitle(NSBundle_MJRefresh.Mj_localizedStringForKey(NSBundle_MJRefresh.Mj_refreshBundle(NSBundle.MainBundle), "MJRefreshHeaderRefreshingText"), MJRefreshState.Refreshing); header.AutomaticallyChangeAlpha = true; footer.RefreshingBlock = async() => { await Task.Delay(2000); InvokeOnMainThread(() => { footer.Hidden = true; this.Count += 5; table.ReloadData(); table.Footer().EndRefreshing(); footer.Hidden = false; }); }; footer.SetTitle(NSBundle_MJRefresh.Mj_localizedStringForKey(NSBundle_MJRefresh.Mj_refreshBundle(NSBundle.MainBundle), "MJRefreshAutoFooterIdleText"), MJRefreshState.Idle); footer.SetTitle(NSBundle_MJRefresh.Mj_localizedStringForKey(NSBundle_MJRefresh.Mj_refreshBundle(NSBundle.MainBundle), "MJRefreshAutoFooterRefreshingText"), MJRefreshState.Refreshing); footer.SetTitle(NSBundle_MJRefresh.Mj_localizedStringForKey(NSBundle_MJRefresh.Mj_refreshBundle(NSBundle.MainBundle), "MJRefreshAutoFooterNoMoreDataText"), MJRefreshState.NoMoreData); table.Header().BeginRefreshing(); // Perform any additional setup after loading the view, typically from a nib. }
protected override void OnElementChanged(ElementChangedEventArgs <ListView> e) { base.OnElementChanged(e); if (e.NewElement != null) { var list = Element as AnimationListView; var tableViewController = ((UITableViewController)ViewController); // add custom color view if (list.EnableRefresh) { UIView view = new UIView() { BackgroundColor = list.HeaderColor.ToUIColor() }; view.Frame = new CoreGraphics.CGRect(0, -tableViewController.TableView.Bounds.Height, tableViewController.TableView.Bounds.Width, tableViewController.TableView.Bounds.Height); tableViewController.TableView.Add(view); } // custom origin refresh control color if (tableViewController.RefreshControl != null) { Console.WriteLine("---------done-------------"); tableViewController.RefreshControl.TintColor = list.RefreshControlColor.ToUIColor(); tableViewController.View.BringSubviewToFront(((UITableViewController)ViewController).RefreshControl); } // add MJRefresh if (list.EnableRefresh) { MJRefreshNormalHeader header = new MJRefreshNormalHeader(); tableViewController.TableView.SetHeader(header); header.RefreshingBlock = () => { list.RefreshCommand.Execute(null); header.EndRefreshing(); }; MJRefreshAutoNormalFooter footer = new MJRefreshAutoNormalFooter(); //footer.Hidden = true; tableViewController.TableView.SetFooter(footer); footer.RefreshingBlock = () => { list.LoadMoreCommand.Execute(null); footer.EndRefreshing(); }; header.LastUpdatedTimeLabel.TextColor = list.HeaderTintColor.ToUIColor(); header.StateLabel.TextColor = list.HeaderTintColor.ToUIColor(); header.ArrowView.TintColor = list.HeaderTintColor.ToUIColor(); footer.StateLabel.TextColor = list.HeaderTintColor.ToUIColor(); tableViewController.TableView.BringSubviewToFront(header); tableViewController.TableView.BringSubviewToFront(footer); } } }
public override void ViewDidLoad() { base.ViewDidLoad(); this.TableView.Frame = new CoreGraphics.CGRect(0, 40, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height - 64 - 40); MJChiBaoZiHeader header = new MJChiBaoZiHeader(); this.TableView.SetHeader(header); MJRefreshAutoNormalFooter footer = new MJRefreshAutoNormalFooter(); this.TableView.SetFooter(footer); header.RefreshingBlock = async() => { await Task.Delay(2000); InvokeOnMainThread(() => { footer.Hidden = true; this.Count += 12; this.TableView.ReloadData(); this.TableView.Header().EndRefreshing(); footer.Hidden = false; }); }; header.SetTitle(NSBundle_MJRefresh.Mj_localizedStringForKey(NSBundle_MJRefresh.Mj_refreshBundle(NSBundle.MainBundle), "MJRefreshHeaderIdleText"), MJRefreshState.Idle); header.SetTitle(NSBundle_MJRefresh.Mj_localizedStringForKey(NSBundle_MJRefresh.Mj_refreshBundle(NSBundle.MainBundle), "MJRefreshHeaderPullingText"), MJRefreshState.Pulling); header.SetTitle(NSBundle_MJRefresh.Mj_localizedStringForKey(NSBundle_MJRefresh.Mj_refreshBundle(NSBundle.MainBundle), "MJRefreshHeaderRefreshingText"), MJRefreshState.Refreshing); header.AutomaticallyChangeAlpha = true; footer.RefreshingBlock = async() => { await Task.Delay(2000); InvokeOnMainThread(() => { footer.Hidden = true; this.Count += 5; this.TableView.ReloadData(); this.TableView.Footer().EndRefreshing(); footer.Hidden = false; }); }; footer.SetTitle(NSBundle_MJRefresh.Mj_localizedStringForKey(NSBundle_MJRefresh.Mj_refreshBundle(NSBundle.MainBundle), "MJRefreshAutoFooterIdleText"), MJRefreshState.Idle); footer.SetTitle(NSBundle_MJRefresh.Mj_localizedStringForKey(NSBundle_MJRefresh.Mj_refreshBundle(NSBundle.MainBundle), "MJRefreshAutoFooterRefreshingText"), MJRefreshState.Refreshing); footer.SetTitle(NSBundle_MJRefresh.Mj_localizedStringForKey(NSBundle_MJRefresh.Mj_refreshBundle(NSBundle.MainBundle), "MJRefreshAutoFooterNoMoreDataText"), MJRefreshState.NoMoreData); this.TableView.Header().BeginRefreshing(); }