private void SetupLayout() { NavigationItem.RightBarButtonItem = new MenuBarButtonItem(this).GetCustomButtom(); if (myCallsTableView == null) { myCallsTableView = new UITableView(); // Fill the whole view with the table (minus top bar and bottom bar) myCallsTableView.ContentInset = new UIEdgeInsets(70, 0, 70, 0); myCallsTableView.Frame = new CGRect(View.Frame.X, View.Frame.Y, View.Frame.Width, View.Frame.Height); // Remove empty cells myCallsTableView.TableFooterView = new UIView(CGRect.Empty); CallSource = new MyCallsSource(callEntity, this); myCallsTableView.Source = CallSource; Add(myCallsTableView); myCallsTableView.ReloadData(); } refreshControl = new UIRefreshControl(); refreshControl.ValueChanged += StartRefresh; myCallsTableView.AddSubview(refreshControl); }
private void InitUI() { nfloat startY = GetStatusBarHeight(); _notesTableView = new UITableView(new CGRect(0, 0, View.Frame.Width, View.Frame.Height - startY)); _notesTableView.RowHeight = 70; _noteSource = new NotesTableSource(null, View.Frame.Width, 70); _noteSource.DeleteNote += DeleteNote; _noteSource.NoteSelected += NoteSelected; this.NavigationItem.SetRightBarButtonItem( new UIBarButtonItem(UIBarButtonSystemItem.Add, (sender, args) => { NavigationController.PushViewController(new AddNoteViewController(_viewModel), false); }) , true); this.NavigationItem.SetLeftBarButtonItem( new UIBarButtonItem("Log out", UIBarButtonItemStyle.Plain, (sender, args) => { UIApplication.SharedApplication.KeyWindow.RootViewController = new UINavigationController(new LoginViewController()); Settings.UserId = string.Empty; }) , true); _refresher = new UIRefreshControl(); _refresher.ValueChanged += Refresh; _notesTableView.AddSubview(_refresher); View.AddSubview(_notesTableView); DialogHelper.DismissProgressDialog(_dialog); }
public override void ViewDidLoad() { base.ViewDidLoad(); NavigationController.NavigationBar.Hidden = false; Title = "Новости"; _tableView = new UITableView() { TranslatesAutoresizingMaskIntoConstraints = false, }; _tableView.Transform = CGAffineTransform.MakeScale(1, -1); _newsTableViewSource = new NewsTableViewSource(ViewModel, _tableView); _mvxRefresh = new MvxUIRefreshControl(); _tableView.AddSubview(_mvxRefresh); _tableView.Source = _newsTableViewSource; _tableView.RowHeight = UITableView.AutomaticDimension; _tableView.EstimatedRowHeight = 60f; _tableView.ReloadData(); View.AddSubview(_tableView); var set = this.CreateBindingSet <NewsController, NewsViewModel>(); set.Bind(_newsTableViewSource).To(vm => vm.News); set.Bind(_mvxRefresh).For(rf => rf.RefreshCommand).To(vm => vm.RefreshNewsCommand); set.Bind(_mvxRefresh).For(rf => rf.IsRefreshing).To(vm => vm.IsBusy); set.Apply(); }
public override void LoadView() { // TODO: Hook up data from view model to View Controller base.LoadView(); _requests = new List <WeatherRequest> { new WeatherRequest { City = new City { Name = "Current Location" } }, new WeatherRequest { City = new City { Name = "Bellevue" } }, new WeatherRequest { City = new City { Name = "San Francisco" } }, new WeatherRequest { City = new City { Name = "London" } } }; View.BackgroundColor = UIColor.White; _tableView = new UITableView(); _tableView.WeakDataSource = this; _tableView.WeakDelegate = this; if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0)) { _tableView.RefreshControl = new UIRefreshControl(); } else { _refreshControl = new UIRefreshControl(); _tableView.AddSubview(_refreshControl); } View.AddSubview(_tableView); this.NavigationItem.SetRightBarButtonItem( new UIBarButtonItem( "Add", UIBarButtonItemStyle.Plain, (sender, args) => { // TODO: Hook into view model actions }), true); }
public override void ViewDidLoad() { base.ViewDidLoad(); Title = Strings.TargetPeople; EdgesForExtendedLayout = UIRectEdge.None; View.BackgroundColor = UIColor.Clear; _refreshControl = new MvxUIRefreshControl(); _tableView = new UITableView(); _tableView.BackgroundColor = UIColor.Clear; _tableView.RowHeight = UITableView.AutomaticDimension; _tableView.EstimatedRowHeight = 44f; _tableView.AddSubview(_refreshControl); _imgBackground = new UIImageView(UIImage.FromBundle("Background.jpg")) { ContentMode = UIViewContentMode.ScaleAspectFill }; _source = new PeopleTableViewSource(_tableView); _tableView.Source = _source; View.AddSubviews(_tableView, _imgBackground); View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); View.AddConstraints( _imgBackground.AtLeftOf(View), _imgBackground.AtTopOf(View), _imgBackground.AtBottomOf(View), _imgBackground.AtRightOf(View), _tableView.AtLeftOf(View), _tableView.AtTopOf(View), _tableView.AtBottomOf(View), _tableView.AtRightOf(View) ); View.BringSubviewToFront(_tableView); var set = this.CreateBindingSet <PeopleView, PeopleViewModel>(); set.Bind(this).For("NetworkIndicator").To(vm => vm.FetchPeopleTask.IsNotCompleted).WithFallback(false); set.Bind(_refreshControl).For(r => r.IsRefreshing).To(vm => vm.LoadPeopleTask.IsNotCompleted).WithFallback(false); set.Bind(_refreshControl).For(r => r.RefreshCommand).To(vm => vm.RefreshPeopleCommand); set.Bind(_source).For(v => v.ItemsSource).To(vm => vm.People); set.Bind(_source).For(v => v.SelectionChangedCommand).To(vm => vm.PersonSelectedCommand); set.Bind(_source).For(v => v.FetchCommand).To(vm => vm.FetchPeopleCommand); set.Apply(); }
// Handle supported edits to the data source (inserts and deletes). public override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath) { // Respond to the user's edit request: Insert a new statistic definition, or delete an existing one. if (editingStyle == UITableViewCellEditingStyle.Insert) { // Create an overlay UI that lets the user choose a field and statistic type to add. _chooseStatOverlay = new ChooseStatisticOverlay(_statPicker); // Handle the OnStatisticDefined event to get the info entered by the user. _chooseStatOverlay.OnStatisticDefined += (s, statDef) => { // Verify the selected statistic doesn't exist in the collection (check for an alias with the same value). StatisticDefinition existingItem = _statisticDefinitions.Find(itm => itm.OutputAlias == statDef.OutputAlias); if (existingItem != null) { return; } // Make updates to the table (add the chosen statistic). tableView.BeginUpdates(); // Insert a new row at the top of table display. tableView.InsertRows(new[] { NSIndexPath.FromRowSection(0, 0) }, UITableViewRowAnimation.Fade); // Insert the chosen statistic in the underlying collection. _statisticDefinitions.Insert(0, statDef); // Apply table edits. tableView.EndUpdates(); }; // Handle when the user chooses to close the dialog. _chooseStatOverlay.OnCanceled += (s, e) => { // Remove the item input UI. _chooseStatOverlay.Hide(); _chooseStatOverlay = null; }; // Add the picker UI view (will display semi-transparent over the table view). tableView.AddSubview(_chooseStatOverlay); _chooseStatOverlay.TranslatesAutoresizingMaskIntoConstraints = false; _chooseStatOverlay.LeadingAnchor.ConstraintEqualTo(tableView.SafeAreaLayoutGuide.LeadingAnchor).Active = true; _chooseStatOverlay.TrailingAnchor.ConstraintEqualTo(tableView.SafeAreaLayoutGuide.TrailingAnchor) .Active = true; _chooseStatOverlay.BottomAnchor.ConstraintEqualTo(tableView.SafeAreaLayoutGuide.BottomAnchor).Active = true; } else if (editingStyle == UITableViewCellEditingStyle.Delete) { // Remove the selected row from the table and the underlying collection of statistic definitions. _statisticDefinitions.RemoveAt(indexPath.Row); tableView.DeleteRows(new[] { indexPath }, UITableViewRowAnimation.Fade); } }
public override void ViewDidLoad() { base.ViewDidLoad(); this.View.AddSubview(tableView); headerView = new UIView(new RectangleF(0, -kRefreshViewHeight, this.View.Frame.Width, kRefreshViewHeight)); headerView.BackgroundColor = UIColor.ScrollViewTexturedBackgroundColor; tableView.AddSubview(headerView); var transform = CATransform3D.Identity; transform.m34 = -1 / 500.0f; headerView.Layer.SublayerTransform = transform; // add the perspective topView = new UIView(new RectangleF(0, -kRefreshViewHeight / 4, headerView.Bounds.Size.Width, kRefreshViewHeight / 2.0f)); topView.BackgroundColor = new UIColor(0.886f, 0.906f, 0.929f, 1); topView.Layer.AnchorPoint = new PointF(0.5f, 0.0f); headerView.AddSubview(topView); topLabel = new UILabel(topView.Bounds); topLabel.BackgroundColor = UIColor.Clear; topLabel.TextAlignment = UITextAlignment.Center; topLabel.Text = "Pull down to refresh"; topLabel.TextColor = new UIColor(0.395f, 0.427f, 0.510f, 1); topLabel.ShadowColor = UIColor.FromWhiteAlpha(1, 0.7f); topLabel.ShadowOffset = new SizeF(0, 1); topView.AddSubview(topLabel); bottomView = new UIView(new RectangleF(0, kRefreshViewHeight * 3 / 4, headerView.Bounds.Size.Width, kRefreshViewHeight / 2)); bottomView.BackgroundColor = new UIColor(0.836f, 0.856f, 0.879f, 1); bottomView.Layer.AnchorPoint = new PointF(0.5f, 1.0f); headerView.AddSubview(bottomView); bottomLabel = new UILabel(bottomView.Bounds); bottomLabel.BackgroundColor = UIColor.Clear; bottomLabel.TextAlignment = UITextAlignment.Center; bottomLabel.TextColor = UIColor.FromRGBA(0.395f, 0.427f, 0.510f, 1); bottomLabel.ShadowColor = UIColor.FromWhiteAlpha(1.0f, 0.7f); bottomLabel.ShadowOffset = new SizeF(0, 1); UpdateLastUpdatedLabel(); bottomView.AddSubview(bottomLabel); // Just so it's not white above the refresh view. var aboveView = new UIView(new RectangleF(0, -this.View.Bounds.Size.Height, this.View.Bounds.Size.Width, this.View.Bounds.Size.Height - kRefreshViewHeight)); aboveView.BackgroundColor = UIColor.FromRGB(0.886f, 0.906f, 0.929f); aboveView.Tag = 123; this.tableView.AddSubview(aboveView); this.TableView.Scrolled += HandleTableViewhandleScrolled; this.TableView.DraggingEnded += HandleTableViewhandleDraggingEnded; }
public override void ViewDidLoad() { View = new UIView() { BackgroundColor = UIColor.White }; base.ViewDidLoad(); ViewModel.Show(); //save user _filePath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "ToDoUser.txt"); File.WriteAllText(_filePath, $"{SignViewModel.UserCurrent.UserLogin}`" + $"{SignViewModel.UserCurrent.UserPassword}"); var _addBarButton = new UIBarButtonItem(UIBarButtonSystemItem.Add); _addBarButton.Title = string.Empty; NavigationItem.RightBarButtonItem = _addBarButton; _table = new UITableView(); _table.RowHeight = 60; RefreshAsync(); AddRefreshControl(); _table.AddSubview(_refresh); var _source = new EditTableViewSource(ViewModel, _table); _table.Source = _source; Add(_table); var set = this.CreateBindingSet <MainView, MainViewModel>(); set.Bind(_addBarButton).To(vm => vm.GoToItem); set.Bind(_source).To(vm => vm.TempListItemsSQL); set.Bind(_source).For(v => v.SelectionChangedCommand).To(vm => vm.ChangeItem); #region with mvvmcross Command //set.Bind(_refresh).For(v => v.IsRefreshing).To(vm => vm.IsLoad); //set.Bind(_refresh).For(r => r.Message).To(vm => vm.LoadMessage); //set.Bind(_refresh).For(v => v.RefreshCommand).To(vm => vm.RefreshCommand); #endregion set.Apply(); _table.ReloadData(); View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); View.AddConstraints(_table.FullWidthOf(View)); View.AddConstraints(_table.FullHeightOf(View)); }
/// <summary> /// Called when a row is touched /// </summary> public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { var url = ""; switch (tableItems[indexPath.Row].Type) { case "Website": //owner.NavigationItem.LeftBarButtonItem = //DisplayModeButtonItem; //owner.NavigationItem.SetRightBarButtonItem( // new UIBarButtonItem(UIBarButtonSystemItem.Undo, (sender, args) => // { // }) //, true); // owner.NavigationItem.Title = tableItems[indexPath.Row].Heading.ToUpper(); //owner.NavigationItem.LeftItemsSupplementBackButton = true; UIBarButtonItem backbutton = new UIBarButtonItem("Back", UIBarButtonItemStyle.Plain, null); backbutton.Clicked += (o, e) => { webView.RemoveFromSuperview(); }; owner.NavigationItem.LeftBarButtonItem = backbutton; webView = new UIWebView(tableView.Bounds); tableView.AddSubview(webView); url = tableItems[indexPath.Row].Url; // NOTE: https secure request webView.ScalesPageToFit = true; webView.LoadRequest(new NSUrlRequest(new NSUrl(url))); break; case "App": default: return; } //webView = new UIWebView(tableView.Bounds); //tableView.AddSubview(webView); // //Title.Replace("Sodexo","Shark"); // //Title = NSBundle.MainBundle.LocalizedString("Sodexo", "Sodexo"); //var url = "https://xamarin.com"; // NOTE: https secure request //webView.LoadRequest(new NSUrlRequest(new NSUrl(url))); //UIAlertController okAlertController = UIAlertController.Create("Row Selected", tableItems[indexPath.Row].Heading, UIAlertControllerStyle.Alert); //okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); //owner.PresentViewController(okAlertController, true, null); tableView.DeselectRow(indexPath, true); }
public override void ViewDidLoad() { base.ViewDidLoad(); table = new UITableView(View.Bounds, UITableViewStyle.Grouped); table.AutoresizingMask = UIViewAutoresizing.All; CreateTableItems(); Add(table); this.refresh += HomeScreen_refresh; UIRefreshControl control = new UIRefreshControl(); control.AttributedTitle = new NSAttributedString("pull to refresh"); control.AddTarget(refresh, UIControlEvent.ValueChanged); table.AddSubview(control); }
private void setLoadingViewStyle(UITableView t) { vLoading = new UIView(new RectangleF(0, 0 - this.View.Bounds.Size.Height, this.View.Bounds.Size.Width, this.View.Bounds.Size.Height)); vLoading.BackgroundColor = UIColor.FromRGB(225, 235, 239); vLoading.Layer.MasksToBounds = true; vLoading.Layer.CornerRadius = 0.0f; UILabel lblTitle = new UILabel() { Font = UIFont.FromName("Helvetica Neue", 14), TextColor = UIColor.FromRGB(25, 119, 156), BackgroundColor = UIColor.Clear }; //frame.size.height - 48.0f, 320.0f, 20.0f lblTitle.Frame = new RectangleF(0, vLoading.Frame.Height - 50, 320, 40); lblTitle.Layer.MasksToBounds = false; lblTitle.Layer.ShadowOffset = new SizeF(0, 1); lblTitle.Layer.ShadowOpacity = 0.5f; lblTitle.Opaque = true; lblTitle.TextAlignment = UITextAlignment.Center; lblTitle.AutoresizingMask = UIViewAutoresizing.FlexibleWidth; lblTitle.Text = "Pull to Refresh..."; vLoading.AddSubview(lblTitle); var imgViewArrow = new UIImageView(UIImage.FromBundle("images/ic_menu_down.png")); imgViewArrow.Frame = new RectangleF(25, vLoading.Frame.Height - 65f, 30, 55); imgViewArrow.ContentMode = UIViewContentMode.ScaleAspectFit; imgViewArrow.Layer.MasksToBounds = true; imgViewArrow.Layer.Transform = CATransform3D.MakeRotation(3.14159265358979323846264338327950288f, 0f, 0f, 1f); vLoading.AddSubview(imgViewArrow); vLoading.AutoresizingMask = UIViewAutoresizing.FlexibleWidth; tableCategory.AddSubview(vLoading); }
public override void ViewDidLoad() { base.ViewDidLoad (); tableView = new UITableView { TranslatesAutoresizingMaskIntoConstraints = false, AllowsSelection = true, SeparatorStyle = UITableViewCellSeparatorStyle.None, }; tableView.BackgroundColor = new UIColor (1f,1f,1f,0.7f); View.AddSubview (tableView); RefreshControl = new UIRefreshControl (); RefreshControl.ValueChanged += async (sender, args) => { await LoadChurches (); RefreshControl.EndRefreshing(); // Signal controller that we are done. }; tableView.AddSubview (RefreshControl); searchBarView = new UIView (new CGRect(0,64,320,30)); searchBar = new UISearchBar (new CGRect(0,0,320,30)); searchBar.Placeholder = "Enter a Church Name, City, or Zip Code"; searchBar.TextChanged += (sender, e) => { //filter main list _subChurches = prayerService.GlobalChurches .Where(c=>c.Name.Contains(e.SearchText) || c.City.Contains(e.SearchText) || c.Zip.Contains(e.SearchText) ).ToList(); if (e.SearchText == default(string)) { _subChurches = prayerService.GlobalChurches; } if (_subChurches.Count > 0){ tableView.Source = new ChurchSource(_subChurches,this,prayerService); tableView.ReloadData(); } }; View.AddSubview (searchBarView); searchBarView.AddSubview (searchBar); }
public override void LoadView() { base.LoadView(); View.BackgroundColor = UIColor.White; _tableView = new UITableView(); _tableView.WeakDataSource = this; _tableView.WeakDelegate = this; if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0)) { _tableView.RefreshControl = new UIRefreshControl(); } else { _refreshControl = new UIRefreshControl(); _tableView.AddSubview(_refreshControl); } View.AddSubview(_tableView); ViewModel.ReloadAction = () => BeginInvokeOnMainThread(_tableView.ReloadData); this.NavigationItem.SetRightBarButtonItem( new UIBarButtonItem( "Add", UIBarButtonItemStyle.Plain, (sender, args) => { ViewModel.AddFavoriteCommand.Execute(null); }), true); Task.Run(async() => { try { await ViewModel.InitAsync(); } catch (Exception ex) { Debug.WriteLine(ex.Message); } }); }
public static void SetEmptyTablePlaceholder(string text, UITableView tableView, nfloat navBarHeight, out UIView placeholderView) { placeholderView = new UIView(new CGRect(0, 0, tableView.Bounds.Width, tableView.Bounds.Height)); var label = new UILabel(new CGRect(tableView.Bounds.Width / 2 - 200 / 2, tableView.Bounds.Height / 2 - 100 / 2 - navBarHeight, 200, 100)) { Text = text, TextAlignment = UITextAlignment.Center, LineBreakMode = UILineBreakMode.WordWrap, Lines = 3, TextColor = UIColor.Gray, Font = UIFont.FromName("Noteworthy", 17) }; placeholderView.AddSubview(label); tableView.AddSubview(placeholderView); }
public override void ViewDidLoad() { this.Title = "Nær deg"; _mapButton = new UIBarButtonItem("Kart", UIBarButtonItemStyle.Bordered, delegate { NavigationController.PushViewController(new MapViewController("Nær deg", _nearbyBusStops.ToArray()), true); }); NavigationItem.RightBarButtonItem = _mapButton; _tableView = new UITableView(View.Bounds, UITableViewStyle.Plain); View.AddSubview(_tableView); _refreshHeaderView = new RefreshTableHeaderView (); _tableView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth; _tableView.AddSubview (_refreshHeaderView); }
public GotoTableViewControllerSource(UITableView tableview) { tableView = tableview; UIColor textColor = ColorUtil.ConvertFromHexColorCode("#ABAEAB"); NoResultLabel = new UILabel(new CGRect(55, 110, 210, 80)); NoResultLabel.Font = UIFont.SystemFontOfSize(14); NoResultLabel.Lines = 0; NoResultLabel.Text = "Use the number pad to go to \nthe page you're looking for."; NoResultLabel.TextAlignment = UITextAlignment.Center; NoResultLabel.TextColor = textColor; tableview.AddSubview(NoResultLabel); pageList = new List <PageSearchItem>(); NSNotificationCenter.DefaultCenter.AddObserver(new NSString("inputPageNumber"), ChangePageNumber); titleLabel.Frame = new CoreGraphics.CGRect(0, 0, 320, 42); titleLabel.TextAlignment = UITextAlignment.Center; titleLabel.Font = UIFont.BoldSystemFontOfSize(17); titleLabel.Text = "Page Not Found"; }
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { UITableViewCell cell = tableView.DequeueReusableCell(cellIdentifier); if (cell == null) { cell = new UITableViewCell(UITableViewCellStyle.Subtitle, cellIdentifier); } UIView parentView = new UIView(); parentView.Frame = new CGRect(0, 0, 60, 50); cell.TextLabel.Text = tableItems[indexPath.Row]; cell.DetailTextLabel.Text = "About " + random.ToString() + " results"; cell.ImageView.ContentMode = UIViewContentMode.ScaleAspectFill; cell.ImageView.Image = new UIImage(imageItems[indexPath.Row]); tableView.RowHeight = 100; tableView.AddSubview(parentView); if (initial) { random = random + new Random().Next(300, 999); } return(cell); }
public override void ViewDidLoad() { base.ViewDidLoad(); Console.WriteLine(Query); this.Title = "Search Results"; var bounds = UIScreen.MainScreen.Bounds; // portrait bounds if (UIApplication.SharedApplication.StatusBarOrientation == UIInterfaceOrientation.LandscapeLeft || UIApplication.SharedApplication.StatusBarOrientation == UIInterfaceOrientation.LandscapeRight) { bounds.Size = new CGSize(bounds.Size.Height, bounds.Size.Width); } // show the loading overlay on the UI thread using the correct orientation sizing this._loadingOverlay = new LoadingOverlay(bounds); this.View.Add(this._loadingOverlay); feedClient = new CLFeedClient(Query, MaxListings, WeeksOld); var result = feedClient.GetAllPostingsAsync(); if (!result) { this._loadingOverlay.Hide(); UIAlertView alert = new UIAlertView(); alert.Message = String.Format("No network connection.{0}Please check your settings", Environment.NewLine); alert.AddButton("OK"); alert.Clicked += (s, ev) => { this.InvokeOnMainThread(() => this.NavigationController.PopViewController(true)); }; this.InvokeOnMainThread(() => alert.Show()); } tableSource = new FeedResultTableSource(this, feedClient); feedResultTable.Source = tableSource; feedResultTable.SeparatorStyle = UITableViewCellSeparatorStyle.None; refreshControl = new UIRefreshControl(); feedResultTable.AddSubview(refreshControl); refreshControl.ValueChanged += (object sender, EventArgs e) => { feedClient.GetAllPostingsAsync(); }; feedClient.asyncLoadingComplete += feedClient_LoadingComplete; feedClient.asyncLoadingPartlyComplete += feedClient_LoadingComplete; feedClient.emptyPostingComplete += (object sender, EventArgs e) => { if (!this._loadingOverlay.AlreadyHidden) { this._loadingOverlay.Hide(); } refreshControl.EndRefreshing(); UIAlertView alert = new UIAlertView(); alert.Message = String.Format("No listings found.{0}Try another search", Environment.NewLine); alert.AddButton("OK"); alert.Clicked += (s, ev) => { this.InvokeOnMainThread(() => this.NavigationController.PopViewController(true)); }; this.InvokeOnMainThread(() => alert.Show()); }; ads.AdLoaded += (object sender, EventArgs e) => { AddAdBanner(true); }; }
// add this string to the extra arguments for mtouch // -gcc_flags "-framework QuartzCore -L${ProjectDir} -lAdMobSimulator3_0 -ObjC" public override void ViewDidLoad() { base.ViewDidLoad (); checkForRefresh = false; reloading = false; list = new List<string>() { "Tangerine", "Mango", "Grapefruit", "Orange", "Banana" }; tableView = new UITableView() { Delegate = new TableViewDelegate(list), DataSource = new TableViewDataSource(list), AutoresizingMask = UIViewAutoresizing.FlexibleHeight| UIViewAutoresizing.FlexibleWidth, //BackgroundColor = UIColor.Yellow, }; // Set the table view to fit the width of the app. tableView.SizeToFit(); // Reposition and resize the receiver tableView.Frame = new RectangleF ( 0, 0, this.View.Frame.Width, this.View.Frame.Height); RefreshTableHeaderView refreshHeaderView = new RefreshTableHeaderView(); refreshHeaderView.BackgroundColor = new UIColor (226.0f,231.0f,237.0f,1.0f); tableView.AddSubview (refreshHeaderView); // Add the table view as a subview this.View.AddSubview(tableView); tableView.DraggingStarted += delegate { checkForRefresh = true; }; tableView.Scrolled += delegate(object sender, EventArgs e) { if (checkForRefresh) { if (refreshHeaderView.isFlipped && (tableView.ContentOffset.Y > - 65.0f) && (tableView.ContentOffset.Y < 0.0f) && !reloading) { refreshHeaderView.flipImageAnimated (true); refreshHeaderView.setStatus (TableViewPullRefresh.RefreshTableHeaderView.RefreshStatus.PullToReloadStatus); } else if ((!refreshHeaderView.isFlipped) && (this.tableView.ContentOffset.Y < -65.0f)) { refreshHeaderView.flipImageAnimated (true); refreshHeaderView.setStatus(TableViewPullRefresh.RefreshTableHeaderView.RefreshStatus.ReleaseToReloadStatus ); } } }; tableView.DraggingEnded += delegate(object sender, EventArgs e) { if (this.tableView.ContentOffset.Y <= -65.0f){ //ReloadTimer = NSTimer.CreateRepeatingScheduledTimer (new TimeSpan (0, 0, 0, 10, 0), () => dataSourceDidFinishLoadingNewData ()); ReloadTimer = NSTimer.CreateScheduledTimer (new TimeSpan (0, 0, 0, 5, 0), delegate { // for this demo I cheated and am just going to pretend data is reloaded // in real world use this function to really make sure data is reloaded ReloadTimer = null; Console.WriteLine ("dataSourceDidFinishLoadingNewData() called from NSTimer"); reloading = false; refreshHeaderView.flipImageAnimated (false); refreshHeaderView.toggleActivityView(); UIView.BeginAnimations("DoneReloadingData"); UIView.SetAnimationDuration(0.3); tableView.ContentInset = new UIEdgeInsets (0.0f,0.0f,0.0f,0.0f); refreshHeaderView.setStatus(TableViewPullRefresh.RefreshTableHeaderView.RefreshStatus.PullToReloadStatus); UIView.CommitAnimations(); refreshHeaderView.setCurrentDate(); }); reloading = true; tableView.ReloadData(); refreshHeaderView.toggleActivityView(); UIView.BeginAnimations("ReloadingData"); UIView.SetAnimationDuration(0.2); this.tableView.ContentInset = new UIEdgeInsets (60.0f,0.0f,0.0f,0.0f); UIView.CommitAnimations(); } checkForRefresh = false; }; }
private void initInterface() { _tvTorrents = new UITableView { Frame = new RectangleF (0, 0, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height - 50) }; _rcRefreshControl = new UIRefreshControl(); _rcRefreshControl.ValueChanged += (sender, e) => { refreshTorrents(); displayTorrents(); }; _tvTorrents.AddSubview (_rcRefreshControl); View.AddSubviews (new UIView[] { _tvTorrents }); LoadTorrents (); displayTorrents (); }
private void initInterface() { _progressHud = new MTMBProgressHUD (this.View); _txtServerHost = new UITextField { Frame = new RectangleF (20, 23, 280, 25) }; _txtServerHost.Placeholder = "Server hostname"; _txtServerHost.BorderStyle = UITextBorderStyle.RoundedRect; _txtServerHost.KeyboardType = UIKeyboardType.Url; _txtServerHost.AutocapitalizationType = UITextAutocapitalizationType.None; _txtServerHost.AutocorrectionType = UITextAutocorrectionType.No; _txtServerHost.ShouldReturn += (textField) => { textField.ResignFirstResponder(); return true; }; _txtServerPort = new UITextField { Frame = new RectangleF (20, 49, 65, 25) }; _txtServerPort.Placeholder = "Port"; _txtServerPort.BorderStyle = UITextBorderStyle.RoundedRect; _txtServerPort.KeyboardType = UIKeyboardType.NumberPad; _txtServerPort.AutocapitalizationType = UITextAutocapitalizationType.None; _txtServerPort.AutocorrectionType = UITextAutocorrectionType.No; _txtServerPort.ShouldReturn += (textField) => { textField.ResignFirstResponder(); return true; }; #if PLUS_VERSION _txtServerPassword = new UITextField { Frame = new RectangleF (85, 49, 215, 25) }; _txtServerPassword.Placeholder = "Password (optional)"; _txtServerPassword.BorderStyle = UITextBorderStyle.RoundedRect; _txtServerPassword.KeyboardType = UIKeyboardType.Default; _txtServerPassword.AutocapitalizationType = UITextAutocapitalizationType.None; _txtServerPassword.AutocorrectionType = UITextAutocorrectionType.No; _txtServerPassword.SecureTextEntry = true; _txtServerPassword.ShouldReturn += (textField) => { textField.ResignFirstResponder(); return true; }; #endif UILabel lblAutoConnect = new UILabel { Frame = new RectangleF (5, 82, 200, 17) }; lblAutoConnect.TextAlignment = UITextAlignment.Right; lblAutoConnect.Text = "Auto-connect at startup"; _swAutoConnect = new UISwitch { Frame = new RectangleF (250, 75, 49, 31) }; _tvServers = new UITableView { Frame = new RectangleF (0, 111, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height - 160) }; _rcRefreshControl = new UIRefreshControl(); _rcRefreshControl.ValueChanged += (sender, e) => { doRefreshServers(); }; _tvServers.AddSubview (_rcRefreshControl); #if PLUS_VERSION View.AddSubviews (new UIView[] { _txtServerHost, _txtServerPort, _txtServerPassword, lblAutoConnect, _swAutoConnect, _tvServers, _progressHud }); #else View.AddSubviews (new UIView[] { _txtServerHost, _txtServerPort, lblAutoConnect, _swAutoConnect, _tvServers }); #endif txtSH = _txtServerHost; txtSP = _txtServerPort; #if PLUS_VERSION txtPW = _txtServerPassword; #endif }
// add this string to the extra arguments for mtouch // -gcc_flags "-framework QuartzCore -L${ProjectDir} -lAdMobSimulator3_0 -ObjC" public override void ViewDidLoad() { base.ViewDidLoad (); checkForRefresh = false; reloading = false; list = new List<string>() { "Tangerine", "Mango", "Grapefruit", "Orange", "Banana" }; tableView = new UITableView() { Delegate = new TableViewDelegate(list), DataSource = new TableViewDataSource(list), AutoresizingMask = UIViewAutoresizing.FlexibleHeight| UIViewAutoresizing.FlexibleWidth, //BackgroundColor = UIColor.Yellow, }; // Set the table view to fit the width of the app. tableView.SizeToFit(); // Reposition and resize the receiver tableView.Frame = new RectangleF ( 0, 0, this.View.Frame.Width, this.View.Frame.Height); RefreshTableHeaderView refreshHeaderView = new RefreshTableHeaderView(); refreshHeaderView.BackgroundColor = new UIColor (226.0f,231.0f,237.0f,1.0f); tableView.AddSubview (refreshHeaderView); // Add the table view as a subview this.View.AddSubview(tableView); tableView.DraggingStarted += delegate { checkForRefresh = true; }; tableView.Scrolled += delegate(object sender, EventArgs e) { if (checkForRefresh) { if (refreshHeaderView.isFlipped && (tableView.ContentOffset.Y > - 65.0f) && (tableView.ContentOffset.Y < 0.0f) && !reloading) { refreshHeaderView.flipImageAnimated (true); refreshHeaderView.setStatus (TableViewPullRefresh.RefreshTableHeaderView.RefreshStatus.PullToReloadStatus); } else if ((!refreshHeaderView.isFlipped) && (this.tableView.ContentOffset.Y < -65.0f)) { refreshHeaderView.flipImageAnimated (true); refreshHeaderView.setStatus(TableViewPullRefresh.RefreshTableHeaderView.RefreshStatus.ReleaseToReloadStatus ); } } }; tableView.DraggingEnded += delegate(object sender, EventArgs e) { if (this.tableView.ContentOffset.Y <= -65.0f){ reloading = true; //Reload your data here refreshHeaderView.toggleActivityView(); UIView.BeginAnimations("ReloadingData"); UIView.SetAnimationDuration(0.2); this.tableView.ContentInset = new UIEdgeInsets (60.0f,0.0f,0.0f,0.0f); UIView.CommitAnimations(); } checkForRefresh = false; }; }