2012-09-10 51 views
1

可能重複:
Zooming a UIScrollView in MonoTouch實施委託的回調方法中的MonoTouch

我需要實現我的應用程序這種Objective-C的委託回調:

-(UIView *) viewForZoomingInScrollView:(UIScrollView *)inScroll { 
    return imageView; 
} 

不過我使用MonoTouch開發我的應用程序,我該如何着手在Mono中實現代表觸摸? (我知道我可能沒有使用關於'在MonoTouch中實現代表'的正確術語,請告知)。

這裏是我需要委託回調的代碼(我需要滾動視圖中的ImageView爲可縮放):

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

     Loader loader = new Loader("/Users/jacknutkins/Documents/ARCSDev"); 
     loader.LoadChart("2"); 
     CGBitmapContext context = loader.GetHiResImage(loader.PaletteFile.RGBPaletteDay); 
     UIImage image = UIImage.FromImage(context.ToImage()); 
     this.View.BackgroundColor = UIColor.Red; 
     RectangleF rect = new RectangleF(0.0f, 0.0f, image.Size.Width, image.Size.Height); 
     //RectangleF rect = new RectangleF(scrollView.Frame.Location, scrollView.Frame.Size); 
     UIImageView imageView = new UIImageView(rect); 
     imageView.Image = image; 
     scrollView.ContentSize = image.Size; 
     scrollView.AddSubview(imageView); 
     scrollView.ClipsToBounds = true; 
     scrollView.SetZoomScale(0.5f, true); 
     Console.WriteLine("View Did Load Done."); 
     // Perform any additional setup after loading the view, typically from a nib. 
    } 

Tysin

回答

3

你只需要添加一個事件處理程序ViewForZoomingInScrollView事件:

scrollView.ViewForZoomingInScrollView += (UIScrollView sv) => 
{ 
    return null; 
};