Swiping UIImageView ofscreen - animation

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!

Related

How to animate closing NSWindow to NSStatusItem?

When you minimize an NSWindow you get a nice animation to the Dock. How to achieve a similar animation for "minimizing" to an NSStatusItem in the menu bar?
I have it set up where the NSStatusItem appears when you close the NSWindow but there is no animation.
I've tried animating the window frame but due to various layout contraints it has a minimum size that gets in the way.
To animate the whole NSWindow is not the right way and will result in a rubbish looking animation. I would suggest to capture a snapshot of the window and adding it to a transparent full screen window to animate layer of the image view. This way its fare more smooth. To get an idea how it could be implemented please take a look at this project on git.
Hope this will help.

Display UIImageView contained in UITableViewCell fullscreen with animation when tapped

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.

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.

NSScrollView scroll position

I currently have a NSView in a NSScrollView.
The NSView is large and I need to scroll to manage the object inside.
I want to draw a static rectangle in the center of the NSView without scrolling.
I want to get the scrolling point (the NSClipPoint?) in the drawRect method of the NSView so that I can draw the rectangle at the last step of drawRect to make it on top.
I have looked through the doc and could only find methods to set the scroll point, not getting it.
How can I get that point?
The answer is [[myScrollView contentView] documentVisibleRect]
I've never tried this, so I don't know if it will actually work or not (and I'm about 8 hours away from my Mac, so I can't give it a shot). But can you subclass the NSClipView that your NSScrollView is using and draw the rectangle in NSClipView's drawRect:? If that doesn't work, what about trying the same thing with the NSScrollView directly?
And if that doesn't work, er...report back and I'll remove this answer so as not to mislead anyone coming from Google. :)

Resources