Display UIImageView contained in UITableViewCell fullscreen with animation when tapped - animation

I've an UIImageView inside an custom UITableViewCell and want it to display fullscreen when I tap on it. I've attached a UITapGestureRecognizer to the UIImageView and the image already resizes. The problem I have right now is that the image only moves inside the cell it is contained in, but it should in fact move out of it. I'd also like to put a black background behind the image.
Any ideas on how to achieve that?

I would say the culprit is most likely either the cell, or the cells content view is clipsToBounds enabled. Setting [cell setClipsToBounds:NO]; should solve this problem.
However, if you're willing to take a new approach to this, it may be beneficial to instead of growing the cells imageView, add a new image above the tableview in the same location as the cell's image view and then grow that. This way you wouldn't have any undesirable behavior like being able to scroll the image view away because the table is still scrollable.

Related

Swiping UIImageView ofscreen

I have a UIImageView that needs to be able to be panned all over the view, pinched and rotated, but the imageView needs to change picture on a swipe movement as well. Any idea on how to accomplish this? I have added a UISwipeGestureRecognizer but that will change the picture on any swipe movement. Ideal would be for me to make the picture animate away and the new one on to the screen once the user drags it of the screen or when it's not visible on the screen for more than 50%. Thanks in advance.
This is exactly what a UIScrollView was made for. Simply add all your UIImageView's to the UIScrollView, position them in the right order, and set .paging = YES. Make sure you also set the correct contentSize, or the UIScrollView won't scroll at all!
Also, check out the delegate methods for how to configure the UIScrollView for zooming. You may need to put the UIImageView's in their own UIScrollView which will enable zooming for that specific UIImageView, but this depends on your needs.
Hope that Helps!

How to temporarily disable UIView background image from responding to mouse clicks in Interface Builder?

I have a UIView background image that I want to use for my view.
Now, on top of this image, I want to have buttons and position them relative to what I see in the image.
The problem is, these buttons were already added to the view before the background image was added. So now when I put the background image, entire view is background image and I am unable to access the buttons underneath it in Xcode.
Is there a way to tell Xcode that I am not interested in the UIView but actually the buttons that appear underneath it?
Check - (void)sendSubviewToBack:(UIView *)view in UIView
Would be something like
[self.view sendSubviewToBack:backgroundImageView];

Cocoa - NSScrollView with large number of items

I have an NSScrollView to which I'm adding a bunch of NSViews that have an NSImage subview. Basically it is a long row of thumbnails contained in a scroll view.
Everything works great... until there are thousands of images in the scroll view (since there is no creation of separate thumbnail images, the images are large but downsized to thumbnail size).
It seems the best thing to do would be to dealloc the images that aren't currently shown in the scroll view, and load them back into memory as they come into view. Does NSView support this type of notification (similar to viewWillAppear: and viewWillDisappear: on iOS).
Also, in ARC mode, how do explicitly tell the OS to unload an image? Will setting the NSImage* to nil do the trick?
I think the best approach would be to create a custom NSView subclass that owns the image subviews:
Code your drawRect: method so that only those images that intersect with the dirtyRect are drawn.
Embed your custom view as the subview of the NSScrollView.
As images are added/removed (if this is even possible) you'll want to recalculate your view size and call [super setFrameSize:] so the scroll view knows to change the scroll bar length etc.
Override setFrameSize to re-layout and modify the size, on the way through, if you change the layout when the view is resized (if you have the concept of layout in your view).
You don't say in your question what issues you are facing; are they memory or performance (or both)? I don't think continually releasing and reallocating the subimages will help you either way.

detect scroll in horizontally uitableviewCell

I have UiTableView containing some data, and I want to scroll the UiTableViewCells horizontally to the left or right to show some UiButtons that act some action relatif to the content of the cell.
How Can I do this?
I'm thinking in creating custom cell, and putting a scrollView in it, May this did the trick?
There is a tutorial for this at http://idevrecipes.com/2011/04/14/how-does-the-twitter-iphone-app-implement-side-swiping-on-a-table/ with sample code. He is using a UISwipeGestureRecognizer to trigger an animation that pushes the cell off the screen.
You could use a swipe gesture recognizer attached to your cell.
You can add a UIScrollView to the contentView of a UITableViewCell. If you want to scroll the content using buttons, simply overlay the UIScrollView with buttons and make them call the various scrolling methods of UIScrollView.
Nested UIScrollView (UITableView inherits from UIScrollView) are quite clever about detecting touch conflicts and resolving the users intended gesture.
https://github.com/JonasGessner/JGScrollableTableViewCell might be what you're looking for. It implements this using a UIScrollView inside the cell (just like the iOS 7 mail app).
(Yes the answer is a bit late, but it's never too late! :P)

iOS. How Do Enable a Transparent Image to Pass Touches to a UIButton Below it?

For an iPad app I am writing I have a container UIView with two subview that are UIView subclasses:
A UIImageView whose image has a portion of it cut away to reveal what is below it.
A UIButton below the UIImageView that is revealed through the cut away portion of the UIImageView.
Since the UIImageView overlaps the UIButton spatially it is preventing touches from reaching the UIButton even though the UIButon is fully visible due to the alpha matte cutout in the UIImageView. How do I allow the UIImageView to pass touches to it's sibling UIButton?
Thanks,
Doug
UIImageView usually won't block touches, UIViews do.
You can set the userInteractionEnabled property on the overlapping views to NO, then touches should go through them.
An other approach would be writing a custom hitTest that redirects the thouches to the button.
In addition to Bastian's answer it was also necessary for me to uncheck the Opaque drawing attribute in interface builder for my UIImageView
Even with user interaction enabled, which is the default value when placing a UIImageView in Interface Builder, the touches should pass through to your button underneath, even if your image view has a solid background. Something else must be going on like a UIView sitting on top of the button.
If you are trying to do something more complex to get touches to pass through to underlying views or a separate view controller whose view is underneath, I created this simple open source library:
https://github.com/natrosoft/NATouchThroughView
The REAMDE and demo show how to use it.

Resources