从UITableViewCell中将UIImageView展开为全屏
我有一个UITableViewCell
的UIImageView
,并希望展开它来填充整个屏幕,我已经安装我的UIGestureRecognizer
并使用此代码来扩大框架:
[UIView animateWithDuration:1.0 animations:^{ [self.ImageView setFrame:[[UIScreen mainScreen] applicationFrame]]; }];
但是, UIImageView
将只扩展到填充UITableViewCell
并不填满整个屏幕。
任何帮助将非常感激。
单元格clipsToBounds设置为是,因此在单元格边界外的视图将不可见
下面的方法将帮助你在单元格中获取图像到全屏,然后将其返回到相同的地方。
您需要将gestureRecognizer添加到imageView并将select器设置为cellImageTapped
声明UIImageView * temptumb,fullview; 作为实例variables。
- (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; }
UITableViewCell
只有当reloaddata或reloadRowsAtIndexPaths时才展开:withRowAnimation否则它不会改变表格的大小,只需要在self.view中添加UIImageView
并隐藏图像视图,当点击单元格图像改变图像视图图像后隐藏图像视图时closures全视图