当前位置: 首页>>代码示例>>C#>>正文


C# UITapGestureRecognizer.AddTarget方法代码示例

本文整理汇总了C#中UITapGestureRecognizer.AddTarget方法的典型用法代码示例。如果您正苦于以下问题:C# UITapGestureRecognizer.AddTarget方法的具体用法?C# UITapGestureRecognizer.AddTarget怎么用?C# UITapGestureRecognizer.AddTarget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UITapGestureRecognizer的用法示例。


在下文中一共展示了UITapGestureRecognizer.AddTarget方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ViewDidLoad

        public override void ViewDidLoad ()
        {
            base.ViewDidLoad ();
            
            NavigationItem.LeftBarButtonItem = new UIBarButtonItem (UIBarButtonSystemItem.Cancel);
            NavigationItem.LeftBarButtonItem.Clicked += (sender, e) => {
                this.NavigationController.PopViewController(true);
            };
            NavigationItem.RightBarButtonItem = new UIBarButtonItem (UIBarButtonSystemItem.Done);

            NavigationItem.RightBarButtonItem.Clicked += async (sender, e) => {
                await SaveCheckin();
            };

            mapView.DidUpdateUserLocation += (sender, e) => {
                if (mapView.UserLocation != null) {
                    CLLocationCoordinate2D coords = mapView.UserLocation.Coordinate;
                    UpdateMapLocation(coords);
                }
            };

            UITapGestureRecognizer doubletap = new UITapGestureRecognizer();
            doubletap.NumberOfTapsRequired = 1; // double tap
            doubletap.AddTarget (this, new ObjCRuntime.Selector("ImageTapped"));
            imageView.AddGestureRecognizer(doubletap); 

            _dataSource = new LocationsDataSource (this);
            tableLocations.Source = _dataSource;

            txtComment.ShouldEndEditing += (tf) => {
                tf.ResignFirstResponder();
                return true;
            };
        }
开发者ID:jeacott,项目名称:Buddy-DotNET-SDK,代码行数:34,代码来源:AddCheckinViewController.cs

示例2: SlideoutNavigationController

        /// <summary>
        /// Initializes a new instance of the <see cref="SlideoutNavigationController"/> class.
        /// </summary>
        public SlideoutNavigationController()
        {
            SlideSpeed = 0.2f;
            SlideWidth = 245f;
            // HACK to detect pan gesture from the whole viewport
            SlideHeight = float.MaxValue;
            LayerShadowing = false;

            _internalMenuViewLeft = new ProxyNavigationController {
                ParentController = this,
                View = { AutoresizingMask = UIViewAutoresizing.FlexibleHeight }
            };
            _internalMenuViewRight = new ProxyNavigationController {
                ParentController = this,
                View = { AutoresizingMask = UIViewAutoresizing.FlexibleHeight }
            };

            _internalMenuViewLeft.SetNavigationBarHidden (DisplayNavigationBarOnLeftMenu, false);
            _internalMenuViewRight.SetNavigationBarHidden (DisplayNavigationBarOnRightMenu, false);

            _internalTopView = new UIViewController { View = { UserInteractionEnabled = true } };
            _internalTopView.View.Layer.MasksToBounds = false;

            _tapGesture = new UITapGestureRecognizer ();
            _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);
        }
开发者ID:jgrozdanov,项目名称:mono-sport,代码行数:38,代码来源:SlideoutNavigationController.cs

示例3: ViewDidLoad

        /// <summary>
        /// On load set the config as per the chat application
        /// </summary>
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //Remove the keyboard on a tap gesture
            var tap = new UITapGestureRecognizer();
            tap.AddTarget(() =>
            {
                this.View.EndEditing(true);
            });
            this.View.AddGestureRecognizer(tap);

            //Get a reference to the chat application
            ChatAppiOS chatApplication = ChatWindow.ChatApplication;

            //Update the settings based on previous values
            LocalServerEnabled.SetState(chatApplication.LocalServerEnabled, false);
            MasterIP.Text = chatApplication.ServerIPAddress;
            MasterPort.Text = chatApplication.ServerPort.ToString();
            LocalName.Text = chatApplication.LocalName;
            EncryptionEnabled.SetState(chatApplication.EncryptionEnabled, false);

            //Set the correct segment on the connection mode toggle
            ConnectionMode.SelectedSegment = (chatApplication.ConnectionType == ConnectionType.TCP ? 0 : 1);
        }
开发者ID:MarcFletcher,项目名称:NetworkComms.Net,代码行数:28,代码来源:Settings.cs

示例4: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.White;
            View.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;

            // Adjust taps/touches required to fit your needs.
            UITapGestureRecognizer tapRecognizer = new UITapGestureRecognizer() {
                NumberOfTapsRequired = 1,
                NumberOfTouchesRequired = 1,
            };
            tapRecognizer.AddTarget((sender) => {
                // The foreach is only necessary if you have more than one touch for your recognizer.
                // For all else just roll with zero, `PointF location = tapRecognizer.LocationOfTouch(0, View);`
                foreach (int locationIndex in Enumerable.Range(0, tapRecognizer.NumberOfTouches)) {
                    PointF location = tapRecognizer.LocationOfTouch(locationIndex, View);
                    UIView newTapView = new UIView(new RectangleF(PointF.Empty, ItemSize)) {
                        BackgroundColor = GetRandomColor(),
                    };
                    newTapView.Center = location;
                    View.Add(newTapView);
                    // Remove the view after it's been around a while.
                    Task.Delay(5000).ContinueWith(_ => InvokeOnMainThread(() => {
                        newTapView.RemoveFromSuperview();
                        newTapView.Dispose();
                    }));
                }
            });
            View.AddGestureRecognizer(tapRecognizer);
        }
开发者ID:patridge,项目名称:UIKitAbuse,代码行数:30,代码来源:PlacingViewsViewController.cs

示例5: 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();
        }
开发者ID:MarcFletcher,项目名称:NetworkComms.Net,代码行数:37,代码来源:ChatWindow.cs

示例6: FinishedLaunching

        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching (UIApplication   app, NSDictionary options)
        {

            UITabBarController tabBarController;

            window = new UIWindow (UIScreen.MainScreen.Bounds);

            //viewController = new TrafficDialogViewController();

            var dv = new TrafficDialogViewController (){
                Autorotate = true
            };

            var tap = new UITapGestureRecognizer ();
            tap.AddTarget (() =>{
                dv.View.EndEditing (true);
            });
            dv.View.AddGestureRecognizer (tap);

            tap.CancelsTouchesInView = false;


            navigation = new UINavigationController ();
            navigation.PushViewController (dv, true);

            window = new UIWindow (UIScreen.MainScreen.Bounds);
            window.MakeKeyAndVisible ();
            window.RootViewController = navigation;  

            return true;
        }
开发者ID:RecursosOnline,项目名称:c-sharp,代码行数:38,代码来源:AppDelegate.cs

示例7: 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);
            }
        }
开发者ID:JavierErdozain,项目名称:Events,代码行数:34,代码来源:HyperLinkControlRenderer.cs

示例8: 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);
        }
开发者ID:sinhpham,项目名称:Harvest_Loss,代码行数:34,代码来源:SlideoutNavigationController.cs

示例9: DismissKeyboardOnBackgroundTap

 /// <summary>
 /// Call it to force dismiss keyboard when background is tapped
 /// </summary>
 public void DismissKeyboardOnBackgroundTap()
 {
     // Add gesture recognizer to hide keyboard
     var tap = new UITapGestureRecognizer { CancelsTouchesInView = false };
     tap.AddTarget(() => Controller.View.EndEditing(true));
     tap.ShouldReceiveTouch = (recognizer, touch) =>
         !(touch.View is UIControl || touch.View.FindSuperviewOfType(Controller.View, typeof(UITableViewCell)) != null);
     Controller.View.AddGestureRecognizer(tap);
 }
开发者ID:pavlob0910,项目名称:my-start-stable,代码行数:12,代码来源:ControllerKeyboardHandler.cs

示例10: RegisterTapGestureRecognizer

		protected void RegisterTapGestureRecognizer ()
		{
			_tapGesture = new UITapGestureRecognizer ();

			_tapGesture.NumberOfTapsRequired = 1;
			_tapGesture.NumberOfTouchesRequired = 1;

			_targetToken = _tapGesture.AddTarget (EndTarget);

			View.AddGestureRecognizer (_tapGesture);
		}
开发者ID:ChuBaka13321,项目名称:customer-success-samples,代码行数:11,代码来源:BaseViewController.cs

示例11: InitGestureRecog

		public void InitGestureRecog ()
		{								
			var gestureRecognizer = new UITapGestureRecognizer();
			gestureRecognizer.CancelsTouchesInView = false;
			gestureRecognizer.AddTarget(this, MySelector);
			
			gestureRecognizer.Delegate = new SwipeRecognizerDelegate();
			
			// and last, add the recognizer to this view to take actions
			this.AddGestureRecognizer(gestureRecognizer);			
		}		
开发者ID:21Off,项目名称:21Off,代码行数:11,代码来源:Map.cs

示例12: SetupTapGesture

 void SetupTapGesture()
 {
     var tapGestureRecognizer = new UITapGestureRecognizer ();
     tapGestureRecognizer.AddTarget (tg =>  {
         var currTapGesture = (tg as UITapGestureRecognizer);
         if (currTapGesture == null)
             return;
         lblGestureStatus.Text = string.Format ("Tap Location: @{0}", currTapGesture.LocationOfTouch (0, imgTapMe));
     });
     tapGestureRecognizer.NumberOfTapsRequired = 2;
     imgTapMe.AddGestureRecognizer (tapGestureRecognizer);
 }
开发者ID:flolovebit,项目名称:xamarin-evolve-2014,代码行数:12,代码来源:GestureRecognizers.cs

示例13: WireUpTapGestureRecognizer

		protected void WireUpTapGestureRecognizer ()
		{
			// create a new tap gesture
			UITapGestureRecognizer tapGesture = new UITapGestureRecognizer ();
			// wire up the event handler (have to use a selector)
			tapGesture.AddTarget ( () => {
				lblGestureStatus.Text = "tap me image tapped @" + tapGesture.LocationOfTouch (0, imgTapMe).ToString ();
			});
			// configure it
			tapGesture.NumberOfTapsRequired = 2;
			// add the gesture recognizer to the view
			imgTapMe.AddGestureRecognizer (tapGesture);
		}
开发者ID:rojepp,项目名称:monotouch-samples,代码行数:13,代码来源:GestureRecognizers_iPhone.xib.cs

示例14: ViewWillAppear

        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            UITapGestureRecognizer scanBarcodeTapped = new UITapGestureRecognizer();
            scanBarcodeTapped.AddTarget(async() =>
            {
                var scanner = new ZXing.Mobile.MobileBarcodeScanner();
                var result = await scanner.Scan();

                Console.WriteLine(result.Text);
            });

            scanBarcodeView.AddGestureRecognizer(scanBarcodeTapped);
        }
开发者ID:MikeCodesDotNet,项目名称:Beer-Drinkin,代码行数:15,代码来源:CheckInViewController.cs

示例15: SlidingCell

        public SlidingCell(string resuseIdentifier)
            : base(UITableViewCellStyle.Default, resuseIdentifier)
        {
            scrollView = new UIScrollView();
            scrollView.ShowsHorizontalScrollIndicator = false;
            scrollView.Delegate = new SlidingCellScrollDelegate(this);
            tapGesture = new UITapGestureRecognizer ();
            tapGesture.AddTarget (() => {
                if (scrollView.ContentOffset != PointF.Empty)
                {
                    scrollView.SetContentOffset(PointF.Empty, false);
                    return;
                }

                var table = this.Superview.Superview as UITableView;
                var indexPath = table.IndexPathForCell (this);
                table.Source.RowSelected (table, indexPath);
            });
            scrollView.AddGestureRecognizer (tapGesture);
            ContentView.AddSubview(scrollView);

            scrollViewButtonView = new UIView();
            scrollView.AddSubview(scrollViewButtonView);

            moreButton = UIButton.FromType(UIButtonType.Custom);
            moreButton.BackgroundColor = UIColor.FromRGBA(0.78f, 0.78f, 0.8f, 1.0f);
            moreButton.SetTitle("More", UIControlState.Normal);
            moreButton.SetTitleColor(UIColor.White, UIControlState.Normal);
            scrollViewButtonView.AddSubview(moreButton);

            deleteButton = UIButton.FromType(UIButtonType.Custom);
            deleteButton.BackgroundColor = UIColor.FromRGBA(1.0f, 0.231f, 0.188f, 1.0f);
            deleteButton.SetTitle("Delete", UIControlState.Normal);
            deleteButton.SetTitleColor(UIColor.White, UIControlState.Normal);
            scrollViewButtonView.AddSubview(deleteButton);

            scrollViewContentView = new UIView();
            scrollViewContentView.BackgroundColor = UIColor.White;
            scrollView.AddSubview(scrollViewContentView);

            scrollViewLabel = new UILabel();

            scrollViewContentView.AddSubview(scrollViewLabel);
            statusView = new UIImageView ();
            scrollView.AddSubview(statusView);
        }
开发者ID:jeffbmiller,项目名称:ShoppingList,代码行数:46,代码来源:SlidingCell.cs


注:本文中的UITapGestureRecognizer.AddTarget方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。