Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
863 views
in Technique[技术] by (71.8m points)

ios - Expand UIImageView to full screen from within UITableViewCell

I have a UIImageView within a UITableViewCell and want to expand it to fill the full screen, I have setup my UIGestureRecognizer and am using 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 does not fill the full screen.

Any help would be much appreciated.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

cells clipsToBounds is set to Yes, so view outside the cell bound will not visible

Following method will help u to get image in cell to full Screen then get it back to same place.

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

Declare UIImageView *temptumb,fullview; as 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;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...