gpt4 book ai didi

ios - 图像在iOS中自动消失

转载 作者:行者123 更新时间:2023-12-01 17:07:54 26 4
gpt4 key购买 nike

当我单击表格单元格时,使用以下代码显示图像imageview。它显示图像,但在1毫秒内消失。
谁能帮我做到这一点。

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
BeaconAdViewController *imageVC = [[BeaconAdViewController alloc] init];
self.tempImg.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:fullImg]]];
imageVC.tempImg.image = self.tempImg.image;
imageVC.view.userInteractionEnabled=YES;

UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismiss)];
[imageVC.view addGestureRecognizer:tapGR];
[self presentViewController:imageVC animated:YES completion:nil];
}

-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
//self.fullImg = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:fullImg]]];
self.tempImg.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:fullImg]]];
}

-(void)dismiss
{
[self dismissViewControllerAnimated:YES completion:nil];
}

提前致谢。

最佳答案

尝试这样做:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
BeaconAdViewController *imageVC = [[BeaconAdViewController alloc] init];
// Change the below
// self.tempImg.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:fullImg]]];
UIImage *theImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:fullImg]]];
imageVC.tempImg.image = theImage;
imageVC.view.userInteractionEnabled=YES;

UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismiss)];
[imageVC.view addGestureRecognizer:tapGR];
[self presentViewController:imageVC animated:YES completion:nil];
}

-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
//self.fullImg = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:fullImg]]];
self.tempImg.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:fullImg]]];
}

-(void)dismiss
{
[self dismissViewControllerAnimated:YES completion:nil];
}

关于ios - 图像在iOS中自动消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24679369/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com