2012-08-10 64 views
0

雙指縮放圖片,我有實現代碼如下 - >自定義單元格 - > UIScrollView中 - >的UIImageView如何在UIScrollView中

如何捏和縮放的UIScrollView ..

- (void)scrollViewDidZoom:(UIScrollView *)aScrollView 
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView 
    methods are not working for me. 

我的代碼是:

- (void)viewDidLoad 
    { 
     objCellfullscreen.scroll.maximumZoomScale = 6.0f; 
     objCellfullscreen.scroll.minimumZoomScale= 0.5f; 
     objCellfullscreen.scroll.scrollEnabled = YES; 
     objCellfullscreen.scroll.contentSize = CGSizeMake(320, 460); 
     objCellfullscreen.scroll.delegate =self; 

    } 
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 
     static NSString *CellIdentifier = @"Cell"; 



     objCellfullscreen =(cellFullScreen *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

      if (objCellfullscreen==nil) { 
       ....... 
       ........... 
       ......... 
     } 
     return objCellfullscreen; 
    } 
- (void)scrollViewDidZoom:(UIScrollView *)aScrollView 
{ 

    CGFloat offsetX = (objCellfullscreen.scroll.bounds.size.width > objCellfullscreen.scroll.contentSize.width)?(objCellfullscreen.scroll.bounds.size.width - objCellfullscreen.scroll.contentSize.width) * 0.5 : 0.0; 
    CGFloat offsetY = (objCellfullscreen.scroll.bounds.size.height > objCellfullscreen.scroll.contentSize.height)?(objCellfullscreen.scroll.bounds.size.height - objCellfullscreen.scroll.contentSize.height) * 0.5 : 0.0; 
    objCellfullscreen.img.center = CGPointMake(objCellfullscreen.scroll.contentSize.width * 0.5 + offsetX,objCellfullscreen.scroll.contentSize.height * 0.5 + offsetY); 

} 

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView 
{ 
    return objCellfullscreen.img; 
} 

謝謝..請幫助。

+0

希望你在.h文件中設置UIScrollView委託也 – 2012-08-10 12:16:48

+0

是coder007 ..... – Mani 2012-08-10 13:22:04

回答

0

你不應該有一個表格視圖內的滾動視圖,因爲UITableView繼承自UIScrollView,這可能是爲什麼一些委託方法的滾動視圖不偶然調用/調用。