gpt4 book ai didi

ios - EXC_BREAKPOINT 当返回到 ScrollView 中的 imgview View 时

转载 作者:行者123 更新时间:2023-11-29 04:02:31 26 4
gpt4 key购买 nike

我从另一个 View 调用一个带有 imgView 的 View ,就像这样在 ScrollView 中

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
ImageViewController *view = [[self.menus objectAtIndex:[indexPath row]] objectForKey:@"VIEW"];
view.imgPath = [[self.menus objectAtIndex:[indexPath row]] objectForKey:@"PATH"];
[self presentViewController:view animated:YES completion:nil];
}

然后我在新 View 中显示图像,如下所示

-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return self.imgView;
}

- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
NSString *path = [[NSBundle mainBundle] pathForResource:self.imgPath ofType:@"png"];
UIImage *image = [[UIImage alloc] initWithContentsOfFile:path];
self.imgView = [[UIImageView alloc] initWithImage:image];
self.imgView.frame = (CGRect){.origin=CGPointMake(0.0f, 0.0f), .size=image.size};
[self.scrollView addSubview:self.imgView];
self.scrollView.contentSize = image.size;
CGRect scrollViewFrame = self.scrollView.frame;
CGFloat scaleWidth = scrollViewFrame.size.width / self.scrollView.contentSize.width;
CGFloat scaleHeight = scrollViewFrame.size.height / self.scrollView.contentSize.height;
CGFloat minScale = MIN(scaleWidth, scaleHeight);
self.scrollView.minimumZoomScale = minScale;
self.scrollView.maximumZoomScale = 1.0f;
self.scrollView.zoomScale = minScale;

[self centerScrollViewContents];
}

- (void)viewDidLoad
{
[super viewDidLoad];

UITapGestureRecognizer *doubleTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(scrollViewDoubleTapped:)];
doubleTapRecognizer.numberOfTapsRequired = 2;
doubleTapRecognizer.numberOfTouchesRequired = 1;
[self.scrollView addGestureRecognizer:doubleTapRecognizer];

UITapGestureRecognizer *twoFingerTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(scrollViewTwoFingerTapped:)];
twoFingerTapRecognizer.numberOfTapsRequired = 1;
twoFingerTapRecognizer.numberOfTouchesRequired = 2;
[self.scrollView addGestureRecognizer:twoFingerTapRecognizer];
}

- (void)centerScrollViewContents {
CGSize boundsSize = self.scrollView.bounds.size;
CGRect contentsFrame = self.imgView.frame;

if (contentsFrame.size.width < boundsSize.width) {
contentsFrame.origin.x = (boundsSize.width - contentsFrame.size.width) / 2.0f;
} else {
contentsFrame.origin.x = 0.0f;
}

if (contentsFrame.size.height < boundsSize.height) {
contentsFrame.origin.y = (boundsSize.height - contentsFrame.size.height) / 2.0f;
} else {
contentsFrame.origin.y = 0.0f;
}

self.imgView.frame = contentsFrame;
}

这一切都没有问题,我可以像这样忽略 View

- (IBAction)BackBtnPress:(id)sender {
[self dismissViewControllerAnimated:YES completion:nil];
}

但是,当我想从 didSelectRowAtIndexPath 再次返回到 ImageView 时,应用程序崩溃,并且我在

处收到 EXC_BREAKPOINT
0x18e2756:  calll  0x1a37a00                 ; symbol stub for: getpid

我尝试过调试,它通过 viewWillAppear 完全没有问题,然后崩溃了

对可能出现的问题有什么想法吗?

谢谢!

编辑

启用僵尸没有帮助,禁用弧线没有任何改变。

最佳答案

我通过在选择行时而不是在加载带有 TableView 的第一个 View 时创建新的 ImageView 来修复它,所以我的 didselectrowatindexpath 看起来像这样

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
ImageViewController *view = [ImageViewController alloc];
view.imgPath = [[self.menus objectAtIndex:[indexPath row]] objectForKey:@"PATH"];
[self presentViewController:view animated:YES completion:nil];
}

关于ios - EXC_BREAKPOINT 当返回到 ScrollView 中的 imgview View 时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15687485/

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