如何在iOS应用中使图像全屏显示

时间:2013-06-05 10:21:41

标签: ios objective-c image fullscreen

我是xcode和Objective c的新手,我想知道如何使用轻击手势让图像全屏触摸... 任何人都可以帮助我吗?

这是我尝试过的代码:

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.

UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
tap.numberOfTapsRequired = 1;
tap.cancelsTouchesInView = NO;
imageView.userInteractionEnabled = YES;
[imageView addGestureRecognizer:tap];
}

-(void)handleTap{
imageView.frame=CGRectMake(0,0,320,480);

}

3 个答案:

答案 0 :(得分:0)

您可以更改图像视图的帧大小,然后自动进入全屏模式。

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture)];
tapGesture.numberOfTapsRequired=1;
[imageView setUserInteractionEnabled:YES];
[imageView addGestureRecognizer:tapGesture];

-(void)handleTapGesture{
    imageView.frame=CGRectMake(0,0,320,480);

}

答案 1 :(得分:0)

// Detecting touches on your UIImageView
UITapGestureRecognizer *myImageViewTapped = [[UITapGestureRecognizer alloc] initWithTarget:self
                                                                               action:@selector(changeFrameOfMyImage)];

myImageViewTapped.cancelsTouchesInView = NO;
[self.view addGestureRecognizer:myImageViewTapped];

//...
//...

-(void)changeFrameOfMyImage {
    myImageView.frame = self.view.frame;
}

可能会做到这一点!

答案 2 :(得分:0)

    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
    tapGesture.numberOfTapsRequired = 1;
    tapGesture.cancelsTouchesInView = NO;
    imageView.userInteractionEnabled = YES;
    [imageView addGestureRecognizer:tapGesture];

    -(void)handleTemplateTap:(UIGestureRecognizer *)sender
    {
         imageview.frame=CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height);
    }