gpt4 book ai didi

ios - 从 JTSImageViewController 解除时重置 View

转载 作者:行者123 更新时间:2023-11-29 10:30:05 25 4
gpt4 key购买 nike

我有一个带有图像的 UITableView。当我向下滚动并选择图像时,单击图像我正在使用以下库使其放大/缩小/平移等。当我回来时,tableview 再次从 0 元素开始向后滚动。我使用的不是 didSelectRow,而是自定义选择器。以前有人在这个图书馆工作过吗?如果需要,我可以发布代码。

https://github.com/jaredsinclair/JTSImageViewController

分配选择器

    AsyncImageView *imageView = [[AsyncImageView alloc] initWithFrame:CGRectMake(10.0f, 0.0f, 300.0f, 300.0f)];
imageView.contentMode = UIViewContentModeScaleAspectFit;

[imageView setUserInteractionEnabled:YES];
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] init];
[tapRecognizer addTarget:self action:@selector(bigButtonTapped:)];
[imageView addGestureRecognizer:tapRecognizer];

方法调用

- (void)bigButtonTapped:(id)sender {

UIView *view = [sender view];
AsyncImageView *imageView1 = (AsyncImageView *)[view viewWithTag:IMAGE_VIEW_TAG];

// Create image info
JTSImageInfo *imageInfo = [[JTSImageInfo alloc] init];
#if TRY_AN_ANIMATED_GIF == 1

#else
imageInfo.image = imageView1.image;
#endif
imageInfo.referenceRect = imageView1.frame;
imageInfo.referenceView = imageView1.superview;
imageInfo.referenceContentMode = imageView1.contentMode;
imageInfo.referenceCornerRadius = imageView1.layer.cornerRadius;

// Setup view controller
JTSImageViewController *imageViewer = [[JTSImageViewController alloc]
initWithImageInfo:imageInfo
mode:JTSImageViewControllerMode_Image
backgroundStyle:JTSImageViewControllerBackgroundOption_Blurred];

// Present the view controller.
[imageViewer showFromViewController:self transition:JTSImageViewControllerTransition_FromOriginalPosition];
}

最佳答案

iOS8 中,JSTImageViewController 似乎不能很好地与 UITableView 配合使用。此问题已在 JSTImageViewControllerGitHub 页面中报告。还提到了一个可能的解决方法:

...Apparently it's the default behaviour to reset the contentOffset after returning from a modal view controller...
...setting the modal presentation style of JTSImageViewController to UIModalPresentationOverFullScreen fixes the issue (since it doesn't remove the hierarchy below it and retains the scroll position I think).

if ([[[UIDevice currentDevice] systemVersion] compare:@"8.0" options:NSNumericSearch] != NSOrderedAscending) 
{
self.modalPresentationStyle = UIModalPresentationOverFullScreen;
}

阅读完整主题 Here

关于ios - 从 JTSImageViewController 解除时重置 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30098917/

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