Expand UIImageView full screen from UITableViewCell

I have a UIImageView inside a UITableViewCell and want to expand it to fill the whole screen, I installed my UIGestureRecognizer and use this code to expand the frame:

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

However, the UIImageView will only expand to fill the UITableViewCell and will not fill the entire screen.

Any help would be greatly appreciated.

+1
source share
2 answers

cell clipsToBounds set to Yes, so viewing outside the cell anchor will not be visible

The following method will help you get the image in the cell full screen, and then return it to the same place.

You need to add gestureRecognizer to imageView and set selector as cellImageTapped

Declare UIImageView * temptumb, fullview; as an instance variable.

 - (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; } 
+9
source

UITableViewCell expands only when reloaddata strong> or reloadRowsAtIndexPaths: withRowAnimation otherwise it will not resize in the table. Just add a UIImageView to self.view and hide the image view when you tap the cell image to change the image image of the image after viewing the hidden image when closed full view

0
source

Source: https://habr.com/ru/post/972188/


All Articles