在 tableView 中显示裁剪图像时出现问题
我有一个自定义的 UITableView,其中有一个标签、2 个按钮和 2 个图像。其中一张图像是从较大图像的中心制作的裁剪图像(在表格视图中点击该裁剪图像时,该图像显示在同一表格视图中)。目前,我正在使用 CGImageCreateWithImageInRect 来裁剪图像。因此,最初,裁剪后的图像显示在表格视图中,当用户点击图像时,单元格的高度会增加以显示替换裁剪后图像的更大(原始)图像。当用户点击另一个裁剪图像时,先前放大的图像将被其裁剪版本替换(并且其单元高度减小),并且当前点击的裁剪图像会像之前一样放大。这个过程继续......当我最初加载裁剪后的图像时,它会完美地发生。问题是,如果图像被放大缩小两次/三次......,表视图中显示的裁剪图像是放大版本裁剪后的图像!看起来裁剪后的图像会被进一步自动裁剪。我制作了一系列裁剪图像和一系列原始图像。在 cellForRowAtIndexPath
方法中,我使用这些数组显示了图像。我最初的猜测是这与单元格重用有关,但我找不到任何相关内容。有什么想法如何解决这个问题吗?
I have a customised UITableView
in which I have a label, 2 buttons and 2 images. One of the images is a cropped image made from the centre of a larger image (which is shown in the same table-view on tapping this cropped image in table-view). Currently, I'm using CGImageCreateWithImageInRect
to crop the image. So initially, the cropped images are shown in table-view and when the user taps the image, the height of cell increases to show the larger(original) image which replaces the cropped image. When the user taps another cropped image, the previously enlarged image is replaced with its cropped version(and its cell height reduced) and the cropped image currently tapped is enlarged as previously. This process continues... When I load the cropped images initially, it happens perfectly.The problem is, if an image is enlarged-reduced twice/thrice..., the cropped image displayed in table-view is a zoomed in version of the cropped image! It seems that the cropped image is further cropped automatically. I've made an array of cropped images and an array of original images. Inside the cellForRowAtIndexPath
method, I've displayed the images using these arrays. My initial guess is that this has something to do with cell reuse, but I could'nt find anything on that. Any ideas how to solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论