static void SetupSelection(UITableView table) { for (var i = 0; i < table.GestureRecognizers.Length; i++) { var r = table.GestureRecognizers[i] as SelectGestureRecognizer; if (r != null) return; } table.AddGestureRecognizer(new SelectGestureRecognizer()); }
void BindGestures(UITableView tableview) { if (HasBoundGestures) { return; } HasBoundGestures = true; var gesture = new UILongPressGestureRecognizer(LongPress); gesture.MinimumPressDuration = 2; tableview.AddGestureRecognizer(gesture); var dismissGesture = new UITapGestureRecognizer(Tap); dismissGesture.CancelsTouchesInView = false; tableview.AddGestureRecognizer(dismissGesture); Table = tableview; }
public override void ViewDidLoad() { base.ViewDidLoad (); UITapGestureRecognizer doubletap = new UITapGestureRecognizer(OnDoubleTap) { NumberOfTapsRequired = 2 // double tap }; var table = new UITableView(new RectangleF(0,50, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height)); string[] configItems = new string[] {"Edit User Information", "Become a Member"}; table.Source = new TableSource(configItems); table.AddGestureRecognizer (doubletap); Add (table); }
void Initialize() { BackgroundColor = UIColor.Clear; Hidden = true; AddressEditText = new FlatTextField { ShowShadow = true, VerticalAlignment = UIControlContentVerticalAlignment.Center, AutocapitalizationType = UITextAutocapitalizationType.None, AutocorrectionType = UITextAutocorrectionType.No }; AddressEditText.Placeholder = Localize.GetValue("AddressSearch"); AddressEditText.AccessibilityLabel = AddressEditText.Placeholder; AddressEditText.TranslatesAutoresizingMaskIntoConstraints = false; CancelButton = new FlatButton(); CancelButton.TranslatesAutoresizingMaskIntoConstraints = false; CancelButton.SetTitle(Localize.GetValue("Cancel"), UIControlState.Normal); FlatButtonStyle.Red.ApplyTo(CancelButton); TableView = new UITableView(new CGRect(), UITableViewStyle.Plain) { BackgroundView = new UIView { BackgroundColor = UIColor.FromRGB(242, 242, 242) }, BackgroundColor = UIColor.FromRGB(242, 242, 242), SeparatorColor = UIColor.Clear, SeparatorStyle = UITableViewCellSeparatorStyle.None, RowHeight = 44, SectionHeaderHeight = 15 }; TableView.AddGestureRecognizer(GetHideKeyboardOnTouchGesture()); var source = new GroupedAddressTableViewSource( TableView, UITableViewCellStyle.Subtitle, new NSString(CellId), CellBindingText, UITableViewCellAccessory.None ); source.CellCreator = CellCreator; TableView.Source = source; AddSubviews(AddressEditText, CancelButton, TableView); AddressEditText.OnKeyDown() .Throttle(TimeSpan.FromMilliseconds(700)) .ObserveOn(SynchronizationContext.Current) .Subscribe(text => ViewModel.TextSearchCommand.ExecuteIfPossible(text)); AddConstraints(new [] { NSLayoutConstraint.Create(AddressEditText, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, this, NSLayoutAttribute.Leading, 1f, 8f), NSLayoutConstraint.Create(AddressEditText, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1f, 22f), NSLayoutConstraint.Create(AddressEditText, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1f, 44f), NSLayoutConstraint.Create(AddressEditText, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, CancelButton, NSLayoutAttribute.Leading, 1f, -9f), NSLayoutConstraint.Create(CancelButton, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, this, NSLayoutAttribute.Trailing, 1f, -8f), NSLayoutConstraint.Create(CancelButton, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1f, 22f), NSLayoutConstraint.Create(CancelButton, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1f, 44f), NSLayoutConstraint.Create(CancelButton, NSLayoutAttribute.Width, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1f, 81f), }); var set = this.CreateBindingSet <AddressPickerView, AddressPickerViewModel> (); set.Bind(source) .For(v => v.ItemsSource) .To(vm => vm.AllAddresses); set.Bind(source) .For(v => v.SelectedCommand) .To(vm => vm.AddressSelected); set.Bind(AddressEditText) .For(v => v.Text) .To(vm => vm.StartingText) .OneWay(); set.Bind(CancelButton) .For("TouchUpInside") .To(vm => vm.Cancel); set.Bind(source) .For(v => v.AddressLocationTypePicker) .To(vm => vm.PickerFilter); set.Apply(); SetNeedsLayout(); }
void BindGestures(UITableView tableview) { if (HasBoundGestures) return; HasBoundGestures = true; var gesture = new UILongPressGestureRecognizer(LongPress); gesture.MinimumPressDuration = 2; tableview.AddGestureRecognizer(gesture); var dismissGesture = new UITapGestureRecognizer(Tap); dismissGesture.CancelsTouchesInView = false; tableview.AddGestureRecognizer(dismissGesture); Table = tableview; }