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


C# UIScrollView.AddGestureRecognizer方法代码示例

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


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

示例1: ViewDidLoad

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			// set the background color of the view to white
			this.View.BackgroundColor = UIColor.Orange;

			this.Title = "Scroll View";

			// create our scroll view
			scrollView = new UIScrollView (
				new CGRect (0, 0, View.Frame.Width
					, View.Frame.Height));
			View.AddSubview (scrollView);

			// create our image view
			imageView = new UIImageView (UIImage.FromFile ("енот2.jpg"));
			scrollView.ContentSize = imageView.Image.Size;
			scrollView.AddSubview (imageView);

			// set allow zooming
			scrollView.MaximumZoomScale = 3f;
			scrollView.MinimumZoomScale = .1f;			
			scrollView.ViewForZoomingInScrollView += (UIScrollView sv) => { return imageView; };
			//solo tap
			UITapGestureRecognizer solotap = new UITapGestureRecognizer(OnSoloTap) {
				NumberOfTapsRequired = 1 // solo tap
			};
			// Create a new Tap Gesture Recognizer
			UITapGestureRecognizer doubletap = new UITapGestureRecognizer(OnDoubleTap) {
				NumberOfTapsRequired = 2 // double tap
			};
			scrollView.AddGestureRecognizer (solotap);
			scrollView.AddGestureRecognizer(doubletap); // detect when the scrollView is double-tapped
		}
开发者ID:SobDee,项目名称:xmrn_ios_projects,代码行数:35,代码来源:ViewController.cs

示例2: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            scrollView = new UIScrollView (
                new RectangleF (0, 0, View.Frame.Width,
                    View.Frame.Height));
            View.AddSubview (scrollView);

            imageView = new UIImageView (UIImage.FromBundle ("heinz-map.png"));

            scrollView.ContentSize = imageView.Image.Size;
            scrollView.AddSubview (imageView);
            scrollView.MaximumZoomScale = 0.7f;
            scrollView.MinimumZoomScale = 0.4f;
            scrollView.ContentOffset = new PointF (0, 500);
            scrollView.ZoomScale = 5f;
            scrollView.ViewForZoomingInScrollView += (UIScrollView svm) => {
                return imageView;
            };

            UITapGestureRecognizer doubletap =  new UITapGestureRecognizer(OnDoubleTap) {
                NumberOfTapsRequired = 2 // double tap
            };
            scrollView.AddGestureRecognizer(doubletap);
        }
开发者ID:cdmedia,项目名称:heinzight,代码行数:26,代码来源:MapViewController.cs

示例3: ViewDidLoad

        public override void ViewDidLoad()
        {
            View.BackgroundColor = UIColor.White;
            PHAsset asset = _imageCache.GetAsset(_image.LocalIdentifier);

            UIImage image = GetImage(asset);

            _imageView = new UIImageView(image)
            {
                MultipleTouchEnabled = true,
                UserInteractionEnabled = true,
                ContentMode = UIViewContentMode.ScaleAspectFit,
                Frame = new CGRect(new CGPoint(0, 0), image.Size),
                AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
            };

            _scrollView = new UIScrollView
            {
                //				Delegate = new ScrollViewDelegate(this),
                Frame = View.Frame,
                AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
            };
            _scrollView.ContentSize = image.Size;

            _scrollView.ViewForZoomingInScrollView += ScrollView_ViewForZoomingInScrollView;
            _scrollView.DidZoom += ScrollView_DidZoom;

            _scrollView.AddSubview(_imageView);
            View.AddSubview(_scrollView);

            //			UpdateImage(asset);

            var doubleTapRecognizer = new UITapGestureRecognizer(ScrollViewDoubleTapped)
            {
                NumberOfTapsRequired = 2,
                NumberOfTouchesRequired = 1
            };
            _scrollView.AddGestureRecognizer(doubleTapRecognizer);

            CGRect scrollViewFrame = _scrollView.Frame;
            nfloat scaleWidth = scrollViewFrame.Size.Width / _scrollView.ContentSize.Width;
            nfloat scaleHeight = scrollViewFrame.Size.Height / _scrollView.ContentSize.Height;
            double minScale = Math.Min(scaleWidth, scaleHeight);
            _scrollView.MinimumZoomScale = (nfloat)minScale;

            _scrollView.MaximumZoomScale = 1;
            _scrollView.ZoomScale = (nfloat)minScale;

            //CenterScrollViewContents();
        }
开发者ID:GSerjo,项目名称:ImagePocket,代码行数:50,代码来源:PhotoViewController2.cs

示例4: 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

示例5: ViewDidLoad

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			var bounds = View.Bounds;
			var screenBounds = UIScreen.MainScreen.Bounds;
			var maxScreenDimension = NMath.Max (screenBounds.Width, screenBounds.Height);

			UIViewAutoresizing flexibleDimensions = FlexibleWidth | FlexibleHeight;

			scrollView = new UIScrollView (bounds) {
				AutoresizingMask = flexibleDimensions
			};
			View.AddSubview (scrollView);

			var frame = new CGRect (CGPoint.Empty, new CGSize (maxScreenDimension, maxScreenDimension));
			cgView = new StrokeCGView (frame) {
				AutoresizingMask = flexibleDimensions
			};

			View.BackgroundColor = UIColor.White;

			canvasContainerView = CanvasContainerView.FromCanvasSize (cgView.Frame.Size);
			canvasContainerView.DocumentView = cgView;
			scrollView.ContentSize = canvasContainerView.Frame.Size;
			scrollView.ContentOffset = new CGPoint ((canvasContainerView.Frame.Width - scrollView.Bounds.Width) / 2,
													(canvasContainerView.Frame.Height - scrollView.Bounds.Height) / 2);
			scrollView.AddSubview (canvasContainerView);
			scrollView.BackgroundColor = canvasContainerView.BackgroundColor;
			scrollView.MaximumZoomScale = 3;
			scrollView.MinimumZoomScale = 0.5f;
			scrollView.PanGestureRecognizer.AllowedTouchTypes = TouchTypes (UITouchType.Direct);
			scrollView.PinchGestureRecognizer.AllowedTouchTypes = TouchTypes (UITouchType.Direct);

			scrollView.Delegate = this;

			// We put our UI elements on top of the scroll view, so we don't want any of the
			// delay or cancel machinery in place.
			scrollView.DelaysContentTouches = false;

			fingerStrokeRecognizer = new StrokeGestureRecognizer (StrokeUpdated) {
				Delegate = this,
				CancelsTouchesInView = false,
				IsForPencil = false,
				CoordinateSpaceView = cgView
			};
			scrollView.AddGestureRecognizer (fingerStrokeRecognizer);

			pencilStrokeRecognizer = new StrokeGestureRecognizer (StrokeUpdated) {
				Delegate = this,
				CancelsTouchesInView = false,
				CoordinateSpaceView = cgView,
				IsForPencil = true
			};
			scrollView.AddGestureRecognizer (pencilStrokeRecognizer);

			SetupConfigurations ();

			var onPhone = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone;

			var ringDiameter = onPhone ? 66f : 74f;
			var ringImageInset = onPhone ? 12f : 14f;
			var borderWidth = 1f;
			var ringOutset = ringDiameter / 2 - (NMath.Floor (NMath.Sqrt ((ringDiameter * ringDiameter) / 8) - borderWidth));
			var ringFrame = new CGRect (-ringOutset, View.Bounds.Height - ringDiameter + ringOutset, ringDiameter, ringDiameter);
			var ringControl = new RingControl (ringFrame, configurations.Length);
			ringControl.AutoresizingMask = FlexibleRightMargin | FlexibleTopMargin;
			View.AddSubview (ringControl);
			leftRingControl = ringControl;
			string [] imageNames = { "Calligraphy", "Ink", "Debug" };
			for (int index = 0; index < leftRingControl.RingViews.Count; index++) {
				var ringView = leftRingControl.RingViews [index];
				ringView.ActionClosure = configurations [index];
				var imageView = new UIImageView (ringView.Bounds.Inset (ringImageInset, ringImageInset));
				imageView.Image = UIImage.FromBundle (imageNames [index]);
				imageView.AutoresizingMask = FlexibleLeftMargin | FlexibleRightMargin | FlexibleTopMargin | FlexibleBottomMargin;
				ringView.AddSubview (imageView);
			}

			clearButton = AddButton ("clear", ClearButtonAction);
			SetupPencilUI ();
		}
开发者ID:xamarin,项目名称:monotouch-samples,代码行数:82,代码来源:CanvasMainViewController.cs

示例6: 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);
        }
开发者ID:hhempel,项目名称:StoryboardTables,代码行数:35,代码来源:imageViewCode.cs

示例7: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            if (Images == null)
            {
                Images = new List<UIImage>();

                foreach (string s in ImagePaths)
                {
                    Images.Add(UIImage.FromBundle(s));
                }
            }

            View.BackgroundColor = UIColor.Black;
            View.AutoresizingMask = UIViewAutoresizing.All;
            totalPage = Images.Count;

            //set View to Full Screen
            WantsFullScreenLayout = true;

            //Add Done button if modal
            if (IsModalView)
            {
                NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, dismissImageViewer);
            }
            //Navigationbar and toolbar styling
            //			NavigationController.NavigationBar.TintColor = UIColor.FromRGB(233, 131, 0);
            NavigationController.NavigationBar.Translucent = true;
            NavigationController.Toolbar.TintColor = UIColor.FromRGB(233, 131, 0);
            NavigationController.Toolbar.Translucent = true;
            NavigationController.SetToolbarHidden(false, false);

            //set X of UIScrollView for UIImageView
            float scrollViewOffset = 0;
            imageSizeWidth = (int)View.Frame.Size.Width;
            imageSizeHeight = (int)View.Frame.Size.Height + 64;

            imageScrollView = new UIScrollView(new RectangleF(0, 0, imageSizeWidth, imageSizeHeight));
            imageScrollView.ContentSize = new SizeF(imageSizeWidth * totalPage, imageSizeHeight);
            imageScrollView.PagingEnabled = true;
            imageScrollView.WeakDelegate = this;
            imageScrollView.AutoresizingMask = UIViewAutoresizing.All;

            //add UIImageViews to UIScrollView
            foreach (UIImage img in Images)
            {
                UIImageView iv = new UIImageView(img);
                iv.AutoresizingMask = UIViewAutoresizing.All;
                iv.ContentMode = UIViewContentMode.ScaleAspectFit;
                iv.Frame = new RectangleF(scrollViewOffset, 0, imageSizeWidth, imageSizeHeight);
                iv.UserInteractionEnabled = true;
                imageScrollView.AddSubview(iv);
                scrollViewOffset += imageSizeWidth;
            }

            View.AddSubview(imageScrollView);

            //set ScrollView to Currentpage
            imageScrollView.ScrollRectToVisible(new RectangleF(CurrentPage * imageSizeWidth, 0, imageSizeWidth, imageSizeHeight), false);

            //show Title with currentpage
            Title = "Afbeelding " + (CurrentPage + 1) + " van " + totalPage;

            //Add UIPageControl to toolbar
            pageControl = new UIPageControl(new RectangleF(0, 0, View.Frame.Size.Width, 40));
            pageControl.Pages = Images.Count;
            pageControl.CurrentPage = CurrentPage;
            pageControl.DefersCurrentPageDisplay = true;
            pageControl.HidesForSinglePage = false;

            UIBarButtonItem[] items = new UIBarButtonItem[]{ new UIBarButtonItem(pageControl) };
            ToolbarItems = items;

            // Detect orientation changes using an observer
            orientationObserver = NSNotificationCenter.DefaultCenter.AddObserver("UIDeviceOrientationDidChangeNotification", handleRotation);

            //Add GestureRecognizer to show/hide navigationbar/toolbar/statusbar
            UITapGestureRecognizer gesture = new UITapGestureRecognizer(this, new MonoTouch.ObjCRuntime.Selector("ViewTapSelector"));
            imageScrollView.AddGestureRecognizer(gesture);
        }
开发者ID:BobStolk,项目名称:EventApp,代码行数:81,代码来源:ImageViewerViewController.cs

示例8: SWTableViewCell

        public SWTableViewCell(UITableViewCellStyle style, string reuseIdentifier,
            UITableView containingTable, IEnumerable<UIButton> rightUtilityButtons,
            UIView leftView, List<UIView> mainView)
            : base(style, reuseIdentifier)
        {
            scrollViewLeft = leftView;
            this.rightUtilityButtons = rightUtilityButtons.ToArray();
            scrollViewButtonViewRight = new SWUtilityButtonView(this.rightUtilityButtons, this);

            containingTableView = containingTable;
            height = (float)containingTableView.RowHeight;
            scrollViewDelegate = new SWScrollViewDelegate(this);

            // Check if the UITableView will display Indices on the right. If that's the case, add a padding
            if (containingTableView.RespondsToSelector(new Selector("sectionIndexTitlesForTableView:"))) {
                string[] indices = containingTableView.Source.SectionIndexTitles(containingTableView);
                additionalRightPadding = indices == null || indices.Length == 0 ? 0 : SectionIndexWidth;
            }

            // Set up scroll view that will host our cell content
            cellScrollView = new UIScrollView(new RectangleF(0, 0, (float)Bounds.Width, height));
            cellScrollView.ContentSize = new SizeF((float)Bounds.Width + UtilityButtonsPadding, height);
            cellScrollView.ContentOffset = ScrollViewContentOffset;
            cellScrollView.Delegate = scrollViewDelegate;
            cellScrollView.ShowsHorizontalScrollIndicator = false;
            cellScrollView.ScrollsToTop = false;
            var tapGestureRecognizer = new UITapGestureRecognizer(OnScrollViewPressed);
            cellScrollView.AddGestureRecognizer(tapGestureRecognizer);

            // Set up the views that will hold the utility buttons
            scrollViewLeft.Frame = new RectangleF(ScrollLeftViewWidth, 0, ScrollLeftViewWidth, height);
            cellScrollView.AddSubview(scrollViewLeft);

            scrollViewButtonViewRight.Frame = new RectangleF((float)Bounds.Width, 0, RightUtilityButtonsWidth, height);

            cellScrollView.AddSubview(scrollViewButtonViewRight);

            // Populate the button views with utility buttons
            scrollViewButtonViewRight.PopulateUtilityButtons();
            // Create the content view that will live in our scroll view
            scrollViewContentView = new UIView(new RectangleF(ScrollLeftViewWidth, 0, (float)Bounds.Width, height));
            cellScrollView.AddSubview(scrollViewContentView);
            this.mainView = mainView;
            BuildMainView();

            AddSubview(cellScrollView);
            HideSwipedContent(false);
        }
开发者ID:strongloop,项目名称:loopback-example-xamarin,代码行数:48,代码来源:SWTableViewCell.cs

示例9: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            if (gvc != null) {
                this.ThumbChanged += (object sender, ThumbChangedEventArgs e) => gvc.ChangeThumb ();
            }

            myBounds = new RectangleF (0, 0, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height);

            scrollView = new UIScrollView (myBounds);

            var documentsDirectory = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
            var gallerydirectory = Path.Combine (documentsDirectory, "gallery");
            string imagefilename = go.imageFileName;
            string path = Path.Combine (gallerydirectory, imagefilename);
            UIImage image = UIImage.FromFile (path);
            var CanvasSize = image.Size;
            RectangleF Canvas = new RectangleF (new PointF (0, 0), CanvasSize);
            //Canvas = new RectangleF (Canvas.X, Canvas.Y, Canvas.Width, Canvas.Height + myBounds.Y);

            //			string thumbfilename = AppDelegate.dao.GetThumbfilenameForIndex (index);
            //			string path = Path.Combine (gallerydirectory, thumbfilename);
            //			Console.WriteLine ("path:" + path);
            //			UIImage currentImage = UIImage.FromFile (path);
            //			SizeF dim = currentImage.Size;

            //create new view if none is availble fr recycling
            //			if (iv == null) {
            iv = new UIImageView(Canvas){
                ContentMode = UIViewContentMode.ScaleAspectFill
            };
            //			}
            iv.Image = image;

            tgv = new TagGraphicsView (go, Canvas);

            scrollView.ContentSize = Canvas.Size;

            scrollView.MaximumZoomScale = 3f;
            scrollView.MinimumZoomScale = 0.3f;

            blend = new UIView (Canvas);
            blend.Frame = Canvas;
            blend.Opaque = true;
            blend.BackgroundColor = UIColor.Clear;
            blend.AddSubview(iv);
            blend.AddSubview(tgv);

            scrollView.AddSubview (blend);

            scrollView.ViewForZoomingInScrollView += (UIScrollView sv) => blend;
            scrollView.SetZoomScale (0.3f, true);
            scrollView.UserInteractionEnabled = true;
            scrollView.AlwaysBounceHorizontal = true;
            scrollView.AlwaysBounceVertical = true;
            Add(scrollView);

            doubletap = new UITapGestureRecognizer (AddTag);
            doubletap.NumberOfTapsRequired = 2;
            scrollView.AddGestureRecognizer (doubletap);

            AddLongPress ();

            CreateEditBarButton ();

            ExtractNewThumbnail();

            //			CreateSlideDownMenu ();

            //			UIButton backbutton = new UIButton(new RectangleF(10,25,48,32));
            //			backbutton.SetImage (backarrow.MakeBackArrow(), UIControlState.Normal);
            //			backbutton.TouchUpInside += (object sender, EventArgs e) => DismissViewControllerAsync (true);
            //			Add (backbutton);

            CreateMenuOptions ();
        }
开发者ID:Skalar,项目名称:Indexer,代码行数:77,代码来源:EditImageModeController.cs

示例10: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            UIGestureRecognizer gesture = new UITapGestureRecognizer ();
            gesture.AddTarget (this, new Selector ("MySelector"));

            RectangleF rect = View.Frame;

            tabsView = new UIScrollView(new RectangleF(0, rect.Bottom - pagerSource.tabHeight, rect.Width, pagerSource.tabHeight));
            tabsView.AddGestureRecognizer (gesture);
            tabsView.BackgroundColor = UIColor.LightGray;
            tabsView.ShowsHorizontalScrollIndicator = false;
            tabsView.ShowsVerticalScrollIndicator = false;
            tabsView.AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin;
            View.Add (tabsView);

            reloadData ();

            SelectTabAtIndex (0);
        }
开发者ID:kyleeverson,项目名称:xamarin-ICViewPager,代码行数:21,代码来源:ICViewPager.cs


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