如何在iOS应用程序中使图像全屏显示
我是xcode和objective c的新手,我想知道如何使用轻触手势使图像在触摸屏上全屏显示。。。 有人能帮我吗 以下是我尝试过的代码:如何在iOS应用程序中使图像全屏显示,ios,objective-c,image,fullscreen,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 act
- (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);
}
您可以更改imageview的帧大小,然后它会自动进入全屏模式
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);
}
这个
可能会成功 谢谢!我要把什么放在哪里?那么我要在.h文件中写什么呢?我刚刚收到一条错误消息:@autoreleasepool{return UIApplicationMain(argc,argv,nil,NSStringFromClass([AppDelegate class]);你在什么时候保存了这段代码?我把它放在viewdiload[super viewdiload]下面,在你的问题中发布你曾经尝试过的代码。在@selector中删除冒号(:)(handleTap:)并重试。检查:-不要忘记imageView.contentMode=UIViewContentModeScaleToFill;
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);
}
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);
}