- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我从另一个 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_BREAKPOINT0x18e2756: 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/
如果我调试我的应用程序。该应用程序在这行代码中崩溃,我收到此警告: 警告: Local declaration of 'imgView' hides instance variable 代码行: [b
我正在使用 ImgViewer v.6 来缩放图像(支持 IE8)。 当图像宽度大于高度时效果很好。但是,当图像较高时,整个高度不会显示在容器中。 http://jsfiddle.net/TheFid
我从另一个 View 调用一个带有 imgView 的 View ,就像这样在 ScrollView 中 - (void)tableView:(UITableView *)tableView didS
我试图通过链接从 Internet 获取图像,并通过按下按钮将其显示在 imageView 上,但图像不会显示。经过一些调试后,我发现该行 imgView.setImageBitmap(myImg);
我是一名优秀的程序员,十分优秀!