本文整理汇总了C#中UITapGestureRecognizer类的典型用法代码示例。如果您正苦于以下问题:C# UITapGestureRecognizer类的具体用法?C# UITapGestureRecognizer怎么用?C# UITapGestureRecognizer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UITapGestureRecognizer类属于命名空间,在下文中一共展示了UITapGestureRecognizer类的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: OnElementChanged
protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
{
base.OnElementChanged(e);
if (e.OldElement == null)
{
var label = Control;
label.TextColor = UIColor.Red;
label.BackgroundColor = UIColor.Clear;
label.UserInteractionEnabled = true;
var tap = new UITapGestureRecognizer();
tap.AddTarget(() =>
{
var hyperLinkLabel = Element as HyperLinkControl;
if (hyperLinkLabel != null)
{
var uri = hyperLinkLabel.NavigateUri;
if (uri.Contains("@") && !uri.StartsWith("mailto:"))
uri = string.Format("{0}{1}", "mailto:", uri);
else if (uri.StartsWith("www."))
uri = string.Format("{0}{1}", @"http://", uri);
UIApplication.SharedApplication.OpenUrl(new NSUrl(uri));
}
});
tap.NumberOfTapsRequired = 1;
tap.DelaysTouchesBegan = true;
label.AddGestureRecognizer(tap);
}
}
示例3: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad();
// ios7 layout
if (RespondsToSelector(new Selector("edgesForExtendedLayout")))
{
EdgesForExtendedLayout = UIRectEdge.None;
}
MvxFluentBindingDescriptionSet<LoginViewController, LoginViewModel> set =
this.CreateBindingSet<LoginViewController, LoginViewModel>();
set.Bind(textField_Email).To(vm => vm.Email);
set.Bind(textField_Password).To(vm => vm.Password);
set.Bind(btn_Login).To(x => x.LoginCommand);
set.Apply();
var gestureRecognizer = new UITapGestureRecognizer(() =>
{
textField_Email.ResignFirstResponder();
textField_Password.ResignFirstResponder();
});
View.AddGestureRecognizer(gestureRecognizer);
}
示例4: ViewDidLoad
/// <summary>
/// On load initialise the example
/// </summary>
public override void ViewDidLoad()
{
base.ViewDidLoad();
//Subscribe to the keyboard events
NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.DidHideNotification, HandleKeyboardDidHide);
NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.DidShowNotification, HandleKeyboardDidShow);
//Remove the keyboard if the screen is tapped
var tap = new UITapGestureRecognizer();
tap.AddTarget(() =>
{
this.View.EndEditing(true);
});
this.View.AddGestureRecognizer(tap);
//Create the chat application instance
ChatApplication = new ChatAppiOS(ChatHistory, MessageBox);
//Uncomment this line to enable logging
//EnableLogging();
//Set the default serializer to Protobuf
ChatApplication.Serializer = DPSManager.GetDataSerializer<NetworkCommsDotNet.DPSBase.ProtobufSerializer>();
//Get the initial size of the chat view
ChatApplication.OriginalViewSize = ChatView.Frame;
//Print out the application usage instructions
ChatApplication.PrintUsageInstructions();
//Initialise comms to add the necessary packet handlers
ChatApplication.RefreshNetworkCommsConfiguration();
}
示例5: BMarkerImageView
public BMarkerImageView(WeakReference parentView, CGPoint location)
{
WeakParent = parentView;
_location = location;
UserInteractionEnabled = true;
Frame = new CGRect (Location.X - 22, Location.Y - 22, 44, 44);
using (var image = UIImage.FromFile ("Images/icon_marker.png"))
{
Image = image;
}
_pan = new UIPanGestureRecognizer (() =>
{
if ((_pan.State == UIGestureRecognizerState.Began || _pan.State == UIGestureRecognizerState.Changed) && (_pan.NumberOfTouches == 1))
{
Center = _pan.LocationInView (_parent);
Location = Center;
_parent.SetNeedsDisplay ();
}
else if (_pan.State == UIGestureRecognizerState.Ended)
{
}
});
_doubleTap = new UITapGestureRecognizer ((gesture) => Crop ()) {
NumberOfTapsRequired = 2, NumberOfTouchesRequired = 1
};
AddGestureRecognizer (_pan);
AddGestureRecognizer (_doubleTap);
}
示例6: 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);
}
示例7: AddGestures
private void AddGestures()
{
var touchDownGesture = new UILongPressGestureRecognizer(HandleTouchDown) { MinimumPressDuration = 0 };
_canvasView.AddGestureRecognizer(touchDownGesture);
// Tap to select
var tapGesture = new UITapGestureRecognizer(HandleTap);
_canvasView.AddGestureRecognizer(tapGesture);
// Move an element
var elementDragGesture = new UIPanGestureRecognizer(HandlePan);
_canvasView.AddGestureRecognizer(elementDragGesture);
elementDragGesture.ShouldBegin = g => _panShouldBegin;
var selectLongPressGesture = new UILongPressGestureRecognizer(HandleLongPress) { MinimumPressDuration = 0.1 };
_canvasView.AddGestureRecognizer(selectLongPressGesture);
selectLongPressGesture.ShouldReceiveTouch = (g, touch) =>
{
var locationInCanvas = touch.LocationInView(_canvasView);
var touchedElement = ElementUnderPoint(locationInCanvas);
return touchedElement != null && !IsElementSelected(touchedElement);
};
selectLongPressGesture.ShouldRecognizeSimultaneously = (g1, g2) => g2 == elementDragGesture;
touchDownGesture.ShouldRecognizeSimultaneously = (g1, g2) => true;
}
示例8: 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);
}
示例9: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
// set the background color of the view to white
this.View.BackgroundColor = UIColor.White;
this.Title = "Mecut Dosya";
// create our scroll view
scrollView = new UIScrollView (
new RectangleF (0, 0, View.Frame.Width
, View.Frame.Height - NavigationController.NavigationBar.Frame.Height));
View.AddSubview (scrollView);
string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
string localFilename = "original.jpg";
string localPath = Path.Combine(documentsPath, localFilename);
// create our image view
imageView = new UIImageView (UIImage.FromFile (localPath));
scrollView.ContentSize = imageView.Image.Size;
scrollView.AddSubview (imageView);
// set allow zooming
scrollView.MaximumZoomScale = 3f;
scrollView.MinimumZoomScale = .1f;
scrollView.ViewForZoomingInScrollView += (UIScrollView sv) => { return imageView; };
// configure a double-tap gesture recognizer
UITapGestureRecognizer doubletap = new UITapGestureRecognizer();
doubletap.NumberOfTapsRequired = 2;
doubletap.AddTarget (this, new MonoTouch.ObjCRuntime.Selector("DoubleTapSelector"));
scrollView.AddGestureRecognizer(doubletap);
}
示例10: OnElementChanged
protected override void OnElementChanged(ElementChangedEventArgs<Image> e)
{
base.OnElementChanged(e);
if (e.NewElement != null)
{
// Get the forms view
_formsView = (HexagonButtonView)e.NewElement;
// Enable user interaction on the image view
this.Control.UserInteractionEnabled = true;
// Set up a tap gesture recognizer
UITapGestureRecognizer tapGesture = null;
Action action = () => {
// Check if the touch is on a transparent part of the image
if (IsPixelTransparent(tapGesture.LocationOfTouch(0, this.Control), this.Control.Image) == false) {
// Execute the click event
_formsView.Click();
}
};
tapGesture = new UITapGestureRecognizer(action);
this.Control.AddGestureRecognizer(tapGesture);
}
}
示例11: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
// Perform any additional setup after loading the view, typically from a nib.
var g = new UITapGestureRecognizer (() => View.EndEditing (true));
g.CancelsTouchesInView = false; //for iOS5
View.AddGestureRecognizer (g);
txtFirst.Text = "John";
txtLast.Text = "Smith";
txtAddress.Text = "123 Nowhere Ln.";
txtCity.Text = "Beverly Hills";
txtState.Text = "CA";
txtZip.Text = "90210-0000";
txtIPAddress.Text = "10.244.43.106";
txtCardNumber.Text = "4832419131427146";
txtExpMonth.Text = "01";
txtExpYear.Text = "2017";
txtCVV.Text = "123";
txtTxnAmount.Text = "12.88";
txtTxnDescription.Text = "Test Transaction";
}
示例12: 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);
}
示例13: SlideoutNavigationController
/// <summary>
/// Initializes a new instance of the <see cref="SlideoutNavigationController"/> class.
/// </summary>
public SlideoutNavigationController()
{
SlideSpeed = 0.2f;
SlideWidth = 260f;
SlideHeight = 44f;
LayerShadowing = true;
_internalMenuView = new ProxyNavigationController
{
ParentController = this,
View = { AutoresizingMask = UIViewAutoresizing.FlexibleHeight }
};
//_internalMenuView.SetNavigationBarHidden(true, false);
_internalTopView = new UIViewController { View = { UserInteractionEnabled = true } };
_internalTopView.View.Layer.MasksToBounds = false;
_tapGesture = new UITapGestureRecognizer();
// _tapGesture.AddTarget(new )
_tapGesture.AddTarget(Hide);
_tapGesture.NumberOfTapsRequired = 1;
_panGesture = new UIPanGestureRecognizer
{
Delegate = new SlideoutPanDelegate(this),
MaximumNumberOfTouches = 1,
MinimumNumberOfTouches = 1
};
_panGesture.AddTarget(() => Pan(_internalTopView.View));
_internalTopView.View.AddGestureRecognizer(_panGesture);
}
示例14: ViewDidLoad
public override void ViewDidLoad(){
this.TableView = new UITableView (this.View.Bounds, UITableViewStyle.Grouped);
base.ViewDidLoad ();
this.View.AddSubview (this.TableView);
UITapGestureRecognizer doubleTap = new UITapGestureRecognizer ();
doubleTap.NumberOfTapsRequired = 2;
this.View.AddGestureRecognizer (doubleTap);
UITapGestureRecognizer twoFingerDoubleTap = new UITapGestureRecognizer ();
twoFingerDoubleTap.NumberOfTapsRequired = 2;
twoFingerDoubleTap.NumberOfTouchesRequired = 2;
this.View.AddGestureRecognizer (twoFingerDoubleTap);
this.SetupLeftButton ();
this.SetupRightButton ();
UIColor barColor = new UIColor (247.0F / 255.0F, 249.0F / 255.0F, 250.0F / 255.0F, 1.0F);
this.NavigationController.NavigationBar.BarTintColor = barColor;
MMLogoView logo = new MMLogoView (new RectangleF (0F, 0F, 29F, 31F));
this.NavigationItem.TitleView = logo;
this.NavigationController.View.Layer.CornerRadius = 10.0F;
UIView backView = new UIView ();
backView.BackgroundColor = new UIColor (208.0F / 255.0F, 208.0F / 255.0F, 208.0F / 255.0F, 1.0F);
this.TableView.BackgroundView = backView;
}
示例15: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// ios7 layout
if (RespondsToSelector(new Selector("edgesForExtendedLayout")))
EdgesForExtendedLayout = UIRectEdge.None;
// Perform any additional setup after loading the view, typically from a nib.
var set = this.CreateBindingSet<AddView, AddViewModel>();
set.Bind(CaptionText).To(vm => vm.Caption);
set.Bind(NotesText).To(vm => vm.Notes);
set.Bind(AddPictureButton).To(vm => vm.AddPictureCommand);
set.Bind(SaveButton).To(vm => vm.SaveCommand);
set.Bind(LocationSwitch).To(vm => vm.LocationKnown);
set.Bind(MainImageView).To(vm => vm.PictureBytes).WithConversion("InMemoryImage");
set.Apply();
var g = new UITapGestureRecognizer(() =>
{
CaptionText.ResignFirstResponder();
NotesText.ResignFirstResponder();
});
View.AddGestureRecognizer(g);
}