2014-01-20 60 views
1

我有一個UITableViewCellUIImageView,並希望將它擴大到充滿整個屏幕,我已經安裝我的UIGestureRecognizer和我使用此代碼擴展框架:展開的UIImageView到全屏幕從內部的UITableViewCell

[UIView animateWithDuration:1.0 animations:^{ 
     [self.ImageView setFrame:[[UIScreen mainScreen] applicationFrame]]; 
}]; 

但是UIImageView只會擴大以填充UITableViewCell並且不會填滿整個屏幕。

任何幫助將不勝感激。

+0

不使用相同的imageView因爲單元格clipsToBounds設置爲是,所以在單元格邊界外的視圖將不可見。檢查我的答案來實現你的功能。 – CoolMonster

回答

0

UITableViewCell不僅擴大時reloaddatareloadRowsAtIndexPaths:withRowAnimation 否則不能更改表的大小,只要你在self.view添加UIImageView和隱藏圖像視圖,當自來水後的細胞圖像來改變圖像視圖圖像當隱藏圖像視圖接近全視圖

9

細胞clipsToBounds設置爲是,所以查看細胞結合的意願 不可見外

下面的方法將幫助你獲得單元格中的圖像到全屏幕然後將它返回到相同的地方。

您需要gestureRecognizer增加的ImageView,並設置選擇爲cellImageTapped

申報的UIImageView * temptumb,fullview;作爲實例變量。

- (void)cellImageTapped:(UIGestureRecognizer *)gestureRecognizer { 
    NSLog(@"%@", [gestureRecognizer view]); 
    //create new image 
    temptumb=(UIImageView *)gestureRecognizer.view; 
    //temptumb=thumbnail; 
    fullview=[[UIImageView alloc]init]; 
     [fullview setContentMode:UIViewContentModeScaleAspectFit]; 
    fullview.image = [(UIImageView *)gestureRecognizer.view image]; 
     CGRect point=[self.view convertRect:gestureRecognizer.view.bounds fromView:gestureRecognizer.view]; 
    [fullview setFrame:point]; 

    [self.view addSubview:fullview]; 

    [UIView animateWithDuration:0.5 
        animations:^{ 
         [fullview setFrame:CGRectMake(0, 
                 0, 
                 self.view.bounds.size.width, 
                 self.view.bounds.size.height)]; 
        }]; 
    UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(fullimagetapped:)]; 
    singleTap.numberOfTapsRequired = 1; 
    singleTap.numberOfTouchesRequired = 1; 
    [fullview addGestureRecognizer:singleTap]; 
    [fullview setUserInteractionEnabled:YES]; 
} 
- (void)fullimagetapped:(UIGestureRecognizer *)gestureRecognizer { 

    CGRect point=[self.view convertRect:temptumb.bounds fromView:temptumb]; 

    gestureRecognizer.view.backgroundColor=[UIColor clearColor]; 
    [UIView animateWithDuration:0.5 
        animations:^{ 
         [(UIImageView *)gestureRecognizer.view setFrame:point]; 
        }]; 
    [self performSelector:@selector(animationDone:) withObject:[gestureRecognizer view] afterDelay:0.4]; 

} 

-(void)animationDone:(UIView *)view 
{ 
    [fullview removeFromSuperview]; 
    fullview=nil; 
}