本文整理汇总了C#中UIView.AddGestureRecognizer方法的典型用法代码示例。如果您正苦于以下问题:C# UIView.AddGestureRecognizer方法的具体用法?C# UIView.AddGestureRecognizer怎么用?C# UIView.AddGestureRecognizer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIView
的用法示例。
在下文中一共展示了UIView.AddGestureRecognizer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterKeyboardDismissalHandler
/**
* Locates all textfields in the given view and registers a handler to dismiss the keyboard when the user clicks 'Done'
*/
public static void RegisterKeyboardDismissalHandler(UIView view)
{
UITapGestureRecognizer gesture = new UITapGestureRecognizer(() => view.EndEditing(true));
gesture.CancelsTouchesInView = false; //for iOS5. Otherwise events will not be fired on other controls.
view.AddGestureRecognizer(gesture);
RegisterKeyboardDoneHandlers (view);
}
示例2: AddGestureRecognizer
protected void AddGestureRecognizer(UIView target, UIGestureRecognizer tap)
{
if (!target.UserInteractionEnabled)
target.UserInteractionEnabled = true;
target.AddGestureRecognizer(tap);
}
示例3: ViewDidLoad
public override void ViewDidLoad()
{
View = new UIView { BackgroundColor = UIColor.White };
base.ViewDidLoad();
// ios7 layout
if (RespondsToSelector(new Selector("edgesForExtendedLayout")))
EdgesForExtendedLayout = UIRectEdge.None;
var textField = new UITextField(new CGRect(10, 10, 240, 40));
Add(textField);
var button = UIButton.FromType(UIButtonType.System);
button.Frame = new CGRect(260, 10, 50, 40);
button.SetTitle("Search", UIControlState.Normal);
Add(button);
var table = new UITableView(new CGRect(0, 50, 320, 430));
Add(table);
var source = new MvxStandardTableViewSource(table, "TitleText Title");
table.Source = source;
var set = this.CreateBindingSet<FirstView, FirstViewModel>();
set.Bind(textField).To(vm => vm.MovieName);
set.Bind(button).To(vm => vm.UpdateCommand);
set.Bind(source).To(vm => vm.FoundMovies);
set.Bind(source).For(s => s.SelectionChangedCommand).To(vm => vm.ItemSelectedCommand);
set.Apply();
View.AddGestureRecognizer(new UITapGestureRecognizer(() => textField.ResignFirstResponder()) {CancelsTouchesInView = false});
}
示例4: ViewDidLoad
public override void ViewDidLoad()
{
View = new UIView(){ BackgroundColor = UIColor.White};
base.ViewDidLoad();
// ios7 layout
if (RespondsToSelector(new Selector("edgesForExtendedLayout")))
EdgesForExtendedLayout = UIRectEdge.None;
var label = new ShapeLabel(new RectangleF(10, 10, 300, 40));
Add(label);
var textField = new UITextField(new RectangleF(10, 50, 300, 40));
Add(textField);
var shapeView = new ShapeView(new RectangleF(60, 90, 200, 200));
Add(shapeView);
var picker = new UIPickerView();
var pickerViewModel = new MvxPickerViewModel(picker);
picker.Model = pickerViewModel;
picker.ShowSelectionIndicator = true;
textField.InputView = picker;
var set = this.CreateBindingSet<FirstView, Core.ViewModels.FirstViewModel>();
set.Bind(label).For(s => s.TheShape).To(vm => vm.Shape);
set.Bind(textField).To(vm => vm.Shape);
set.Bind(pickerViewModel).For(p => p.ItemsSource).To(vm => vm.List);
set.Bind(pickerViewModel).For(p => p.SelectedItem).To(vm => vm.Shape);
set.Bind(shapeView).For(s => s.TheShape).To(vm => vm.Shape);
set.Apply();
var g = new UITapGestureRecognizer(() => textField.ResignFirstResponder());
View.AddGestureRecognizer(g);
}
示例5: ViewDidLoad
public override void ViewDidLoad()
{
View = new UIView {BackgroundColor = UIColor.White};
NavigationItem.Title = "Search Movies";
base.ViewDidLoad ();
UITextField keywordView = CreateAndAddKeywordView();
UIButton searchButton = CreateAndAddSearchButton();
UITableView tableView = CreateAndAddTableView();
var source = new MvxStandardTableViewSource(tableView, "TitleText title;");
var bindingSet = this.CreateBindingSet<FirstView, FirstViewModel>();
bindingSet.Bind(source).To(viewModel => viewModel.Movies);
bindingSet.Bind(keywordView).To(viewModel => viewModel.Keyword);
bindingSet.Bind(searchButton).To(viewModel => viewModel.SearchCommand);
bindingSet.Bind(source).For(x => x.SelectionChangedCommand).To(viewModel => viewModel.ShowDetailCommand);
bindingSet.Apply();
tableView.Source = source;
tableView.ReloadData();
var responder = new UITapGestureRecognizer (() => keywordView.ResignFirstResponder ());
responder.CancelsTouchesInView = false;
View.AddGestureRecognizer(responder);
}
示例6: TapGestureAttacher
public TapGestureAttacher (UIView view, int tapCount, Action handler)
{
var tap = new UITapGestureRecognizer (handler);
tap.NumberOfTapsRequired = (uint)tapCount;
view.AddGestureRecognizer (tap);
}
示例7: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
view1 = new UIImageView (UIImage.FromFile ("monkey1.png")) {
Frame = View.Frame,
ContentMode = UIViewContentMode.ScaleAspectFit
};
View.AddSubview (view1);
view2 = new UIImageView (UIImage.FromFile ("monkey2.png")) {
Frame = View.Frame,
ContentMode = UIViewContentMode.ScaleAspectFit
};
view1.UserInteractionEnabled = true;
view1.AddGestureRecognizer (new UITapGestureRecognizer (() => {
UIView.Transition (
fromView: view1,
toView: view2,
duration: 2,
options: UIViewAnimationOptions.TransitionFlipFromTop | UIViewAnimationOptions.CurveEaseInOut,
completion: () => { Console.WriteLine ("transition complete"); });
}));
}
示例8: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
View.BackgroundColor = UIColor.White;
fromView = new UIImageView (UIImage.FromFile ("monkey1.png")) {
Frame = View.Frame,
ContentMode = UIViewContentMode.ScaleAspectFit,
UserInteractionEnabled = true
};
View.AddSubview (fromView);
toView = new UIImageView (UIImage.FromFile ("monkey2.png")) {
Frame = View.Frame,
ContentMode = UIViewContentMode.ScaleAspectFit,
UserInteractionEnabled = true
};
View.AddSubview (fromView);
var options = UIViewAnimationOptions.TransitionFlipFromTop | UIViewAnimationOptions.CurveEaseInOut;
fromView.AddGestureRecognizer (new UITapGestureRecognizer (() => UIView.Transition (fromView, toView, 2, options, () => Console.WriteLine ("transition complete"))));
toView.AddGestureRecognizer (new UITapGestureRecognizer (() => {
var initalViewController = (ViewController)MainStoryboard.InstantiateViewController("InitalViewController");
initalViewController.ModalTransitionStyle = UIModalTransitionStyle.CrossDissolve;
PresentViewController(initalViewController, true, null);
}));
}
示例9: EnsureFilterPanelCreated
void EnsureFilterPanelCreated()
{
if (null == _filterOptions)
{
_overlay = new UIView();
_overlay.AddGestureRecognizer(new UITapGestureRecognizer(ToggleFilterPanel));
_overlay.Frame = new RectangleF(PointF.Empty, View.Frame.Size);
_filterOptions = new UIPickerView();
_filterOptions.BackgroundColor = UIColor.White;
_overlay.AddSubview(_filterOptions);
_filterModel = new MvxPickerViewModel(_filterOptions);
_filterModel.ItemsSource = new[] {
"Alle",
"Bøker",
"CDer",
"Filmer",
"Journaler",
"Lydbøker",
"Noter",
"Spill",
"Annet"
};
_filterModel.SelectedItem = "Alle";
_filterModel.SelectedItemChanged += HandleFilterChanged;
_filterOptions.Model = _filterModel;
}
}
示例10: RangeSlider
public RangeSlider()
{
_background = new UIView();
_background.BackgroundColor = UIColor.LightGray;
_range = new UIView();
_range.BackgroundColor = UIColor.Blue;
_leftIndicator = CreateIndicator();
_leftIndicatorGesture = new UIPanGestureRecognizer(OnPan);
_rightIndicator = CreateIndicator();
_rightIndicatorGesture = new UIPanGestureRecognizer(OnPan);
_leftTouchArea = new UIView();
_leftTouchArea.BackgroundColor = UIColor.Clear;
_leftTouchArea.AddGestureRecognizer(_leftIndicatorGesture);
_rightTouchArena = new UIView();
_rightTouchArena.BackgroundColor = UIColor.Clear;
_rightTouchArena.AddGestureRecognizer(_rightIndicatorGesture);
AddSubview(_background);
AddSubview(_range);
AddSubview(_leftIndicator);
AddSubview(_rightIndicator);
AddSubview(_leftTouchArea);
AddSubview(_rightTouchArena);
}
示例11: ViewDidLoad
public override void ViewDidLoad()
{
View = new UIView(){ BackgroundColor = UIColor.White};
base.ViewDidLoad();
// ios7 layout
if (RespondsToSelector(new Selector("edgesForExtendedLayout")))
EdgesForExtendedLayout = UIRectEdge.None;
var binaryEdit = new BinaryEdit(new RectangleF(10, 70, 300, 120));
Add(binaryEdit);
var textField = new UITextField(new RectangleF(10, 190, 300, 40));
Add(textField);
var nicerBinaryEdit = new NicerBinaryEdit(new RectangleF(10, 260, 300, 120));
Add(nicerBinaryEdit);
var set = this.CreateBindingSet<FirstView, Core.ViewModels.FirstViewModel>();
// to remove the need for `For("N28")` see Setup.FillBindingNames
set.Bind(binaryEdit).For("N28").To(vm => vm.Counter);
set.Bind(textField).To(vm => vm.Counter);
// to remove the need for `For(be => be.MyCount)` see Setup.FillBindingNames
set.Bind(nicerBinaryEdit).For(be => be.MyCount).To(vm => vm.Counter);
set.Apply();
var tap = new UITapGestureRecognizer(() => textField.ResignFirstResponder());
View.AddGestureRecognizer(tap);
}
示例12: ViewDidLoad
public override void ViewDidLoad()
{
View = new UIView(){ BackgroundColor = UIColor.White};
base.ViewDidLoad();
// ios7 layout
if (RespondsToSelector(new Selector("edgesForExtendedLayout")))
EdgesForExtendedLayout = UIRectEdge.None;
var textFieldTitle = new UITextField(new RectangleF(10, 10, 300, 30));
Add(textFieldTitle);
var picker = new UIPickerView();
var pickerViewModel = new MvxPickerViewModel(picker);
picker.Model = pickerViewModel;
picker.ShowSelectionIndicator = true;
textFieldTitle.InputView = picker;
var textFieldFirstName = new UITextField(new RectangleF(10, 40, 300, 30));
Add(textFieldFirstName);
var textFieldLastName = new UITextField(new RectangleF(10, 70, 300, 30));
Add(textFieldLastName);
var acceptedLabel = new UILabel(new RectangleF(10, 100, 200, 30));
acceptedLabel.Text = "Accepted?";
Add(acceptedLabel);
var accepted = new UISwitch(new RectangleF(210, 100, 100, 30));
Add(accepted);
var add = new UIButton(UIButtonType.RoundedRect);
add.SetTitle("Add", UIControlState.Normal);
add.TintColor = UIColor.Purple;
add.Frame = new RectangleF(10,130,300,30);
Add(add);
var table = new UITableView(new RectangleF(10, 160, 300, 300));
Add(table);
var source = new MvxStandardTableViewSource(table, "TitleText FirstName");
table.Source = source;
var set = this.CreateBindingSet<FirstView, Core.ViewModels.FirstViewModel>();
set.Bind(textFieldFirstName).To(vm => vm.FirstName);
set.Bind(textFieldLastName).To(vm => vm.LastName);
set.Bind(pickerViewModel).For(p => p.ItemsSource).To(vm => vm.Titles);
set.Bind(pickerViewModel).For(p => p.SelectedItem).To(vm => vm.Title);
set.Bind(textFieldTitle).To(vm => vm.Title);
set.Bind(accepted).To(vm => vm.Accepted);
set.Bind(add).To("Add");
set.Bind(source).To(vm => vm.People);
set.Apply();
var tap = new UITapGestureRecognizer(() =>
{
foreach (var view in View.Subviews)
{
var text = view as UITextField;
if (text != null)
text.ResignFirstResponder();
}
});
View.AddGestureRecognizer(tap);
}
示例13: FirstResponderResigner
public FirstResponderResigner (UIView view, UIControl control)
{
this.control = control;
var tap = new UITapGestureRecognizer (() => {
control.ResignFirstResponder ();
});
tap.NumberOfTapsRequired = 1;
view.AddGestureRecognizer (tap);
}
示例14: Easter
public Easter(UIView viewForGestures, params Egg[] eggs)
: base(eggs)
{
swipeUp = new UISwipeGestureRecognizer (() => AddCommand (new SwipeUpCommand()));
swipeUp.Direction = UISwipeGestureRecognizerDirection.Up;
viewForGestures.AddGestureRecognizer (swipeUp);
swipeDown = new UISwipeGestureRecognizer (() => AddCommand (new SwipeDownCommand()));
swipeDown.Direction = UISwipeGestureRecognizerDirection.Down;
viewForGestures.AddGestureRecognizer (swipeDown);
swipeLeft = new UISwipeGestureRecognizer (() => AddCommand (new SwipeLeftCommand()));
swipeLeft.Direction = UISwipeGestureRecognizerDirection.Left;
viewForGestures.AddGestureRecognizer (swipeLeft);
swipeRight = new UISwipeGestureRecognizer (() => AddCommand (new SwipeRightCommand()));
swipeRight.Direction = UISwipeGestureRecognizerDirection.Right;
viewForGestures.AddGestureRecognizer (swipeRight);
tap = new UITapGestureRecognizer (() => AddCommand (new TapCommand()));
tap.NumberOfTapsRequired = 1;
viewForGestures.AddGestureRecognizer (tap);
longTap = new UILongPressGestureRecognizer (() => AddCommand (new LongTapCommand()));
longTap.NumberOfTapsRequired = 1;
viewForGestures.AddGestureRecognizer (longTap);
}
示例15: CollapsibleSection
public CollapsibleSection(string caption, bool isCollapsed)
: base(caption)
{
this.isCollapsed = isCollapsed;
imageView = new UIImageView(new RectangleF(300,0,20,20));
imageView.Image = isCollapsed ? UIImage.FromBundle("chevrondown.png") : UIImage.FromBundle("chevronup.png");
HeaderView = new UIView(new RectangleF(0,0,200,20));
titleLabel = new UILabel(new RectangleF(5,0,200,20));
titleLabel.BackgroundColor = UIColor.Clear;
titleLabel.Text = caption;
HeaderView.AddSubview(titleLabel);
HeaderView.BackgroundColor = UIColor.LightGray;
HeaderView.AddSubview(imageView);
HeaderView.AddGestureRecognizer(new UITapGestureRecognizer(x => SectionTapped() ));
}