forked from arlm/StoryboardTables
-
Notifications
You must be signed in to change notification settings - Fork 0
/
imageViewCode.cs
80 lines (56 loc) · 2.22 KB
/
imageViewCode.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// This file has been autogenerated from a class added in the UI designer.
using System;
using System.Drawing;
using MonoTouch.UIKit;
using MonoTouch.Foundation;
using System.IO;
namespace StoryboardTables
{
public partial class imageViewCode : UIViewController
{
public string ImgUrl{ get; set;}
public imageViewCode (IntPtr handle) : base (handle)
{
}
UIScrollView scrollView;
UIImageView imageView;
#region -= constructors =-
#endregion
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);
}
// implement the double-tap handler
[MonoTouch.Foundation.Export("DoubleTapSelector")]
public void OnDoubleTap (UIGestureRecognizer sender) {
if (scrollView.ZoomScale >= 1)
scrollView.SetZoomScale(0.25f, true);
else
scrollView.SetZoomScale(2f, true);
}
}
}