Re: UITableView with multiple UIScrollView each having its own zoom scale?
Re: UITableView with multiple UIScrollView each having its own zoom scale?
- Subject: Re: UITableView with multiple UIScrollView each having its own zoom scale?
- From: Laurent Daudelin <email@hidden>
- Date: Wed, 08 Aug 2012 00:27:03 -0700
I've seen a couple of replies and I thank you guys.
However, there isn't any resizing of the scrollview involved: the scrollview has a fixed size inside the cell, no matter the orientation. The problem is that I calculate the zoom scale based on the image width (in UIImageView that contains the image) and then compare this to the scrollview size. By reducing the zoom scale, I "fit" the image completely in the scrollview:
UIImage *postImage = [UIImage imageWithData:[dictionary objectForKey:POST_PHOTO_DATA_KEY]];
self.postPictureView.image = postImage;
self.postPictureView.frame = CGRectMake(0.0f, 0.0f, postImage.size.width, postImage.size.height);
minimumScale = [self.imageScrollView frame].size.width / [self.postPictureView frame].size.width;
[self.imageScrollView setMinimumZoomScale:minimumScale];
self.imageScrollView.zoomScale = minimumScale;
Initially, the images appear fine in the table view. However, when I start scrolling down, then back up, the images that appeared fine are now zoomed in like 10 times as you could see on the 3rd screen shot. There was no resizing of any cell involved, just scrolling up to hide the cell toward the top of the table view, then scrolling down to come back to the top cell. That's when the images get all zoomed in.
If that gets too complicated, I will rely on a detail view and will forget about providing the ability to zoom images in the table view.
-Laurent.
--
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin http://www.nemesys-soft.com/
Logiciels Nemesys Software email@hidden
On Aug 7, 2012, at 23:11, Roland King <email@hidden> wrote:
> I don't see anything with UITableView reusing cells which should get in your way. Despite seeing the pictures I'm not totally sure what you're trying to accomplish either.
>
> 'Fit completely' means fit in the X-direction, across the cell?
>
> If I understand properly your custom table view cell has, on the content view, a UIScrollView, and on that is the image? Is there a reason you can't pin the UIScrollView to the cells content view so it's resized when the cell changes size, and subclass the UIScrollView, using layoutSubviews to set the bounds of the UIImageView so it always fits, just changing the bounds of a UIImageView resizes the content for you, no need to mess about with zoom scales on the scrollview at all.
>
> Which way are your UIScrollViews scrolling by the way, if it's in the same direction as the UITableView, how well does that actually work?
>
> On 8 Aug, 2012, at 6:58 AM, Laurent Daudelin <email@hidden> wrote:
>
>> I've been trying to get my UITableView with custom UITableViewCells, each one containing a different image and potentially each one having a different zoom scale, but I'm seeing weird behavior and I'm starting to think that due to the way UITableViewCells are reused, this might not be possible.
>>
>> I have an array of NSDictionary that have one object containing the data of a UIImage. I initially set the zoom scale so that the picture in each cell will fit completely, scaling down the zoom of the UIScrollView embedding the UIImageView.
>>
>> However, when I start scrolling up and down, at some point, some images, which initially appeared fine, all of a sudden appear all the way zoomed in. I check the zoom factor in tableView:cellForRowAtIndexPath: when I configure the cell that the UITableView is requesting and maybe I'm missing something, but in each case, the zoom scale factor seems to be the same. However, on screen, the image is clearly zoomed quite a bit. I started off from the TapToZoom project part of the ZoomSuite sample.
>>
>> Anybody knows if this would be possible or not? I'd hate wasting my time beating a dead horse if, due to the nature of UITableView re-using UITableViewCell, this would not be possible.
>>
>> Any comment appreciated.
>>
>> -Laurent.
>> --
>> Laurent Daudelin
>> AIM/iChat/Skype:LaurentDaudelin http://www.nemesys-soft.com/
>> Logiciels Nemesys Software email@hidden
>>
>>
>> _______________________________________________
>>
>> Cocoa-dev mailing list (email@hidden)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden