I have a storyboard that at some point moves from one view to another, but the animations that area available to the segway are Cover Vertically, Flip Horizontally, Cross dissolve and partial curl. I need to have a "Slide to the right" animation. How can I add this?
Also, I'm able to use this kind of animations if the segue is Modal type, which as I understand is a view being drawn over the other view. I would like to "Push", as I understand pushing discards the past view.
Related
I have a SectionList which scrolls/swipes vertically. Can I bind a swipe gesture on it, so that it results in swiping a completely separate View which is behind it? Furthermore, is there an example someone could lead me to, in which a swipe gesture on a SectionList is bound to the animation of another object or objects? Here is a good example of what I am trying to achieve:
When the view is scrolled vertically in the example above it causes a menu to animate in from the top. That is close to the desired effect I'm seeking. I'd also love to know how to achieve that rotational animation tied to the horizontal swipe. I'm thinking that I will likely need the Animated API for this kind of behavior. Any tutorials or code examples you have would really help.
I'm trying to create a timeline control in Cocoa. This is what I am trying to achieve. It's basically a standard timeline design.
However, I don't know which approach to take. The problem lies with the top ruler, the left track list and the bottom audio waveform display. These three parts need to always be visible and 'stick' to the edges. The ruler and audio waveform should only scroll horizontally, while the track list on the left should only scroll vertically.
For the top ruler, NSRulerView seems appropriate since it's just a ruler.
For the left view and the bottom view I don't know which route to take. I've played with using a wide vertical NSRulerView for the track list. This works but creates additional problems. For example: the top ruler appears above the track list.
I've composed four options so far:
Forget NSRulerView and draw everything custom in the document view. This seems feasible but sidesteps built in NSRulerView functions. Also, I need to find a way to shorten the scrollbars so they don't overlap the side and top views.
Use NSRulerViews for the top and left side. The bottom side will then probably be drawn manually in the document view.
Place the left view outside the scrollview and manually scroll it up and down by linking it to the main scroll view. Use NSRulerView for the top, manually draw audio waveform in document view.
An NSScrollView embedded in another NSScrollView. The outer handles horizontal scrolling, the inner scroll view handles vertical scrolling. Possible I think, but it seems hacky.
So my question boils down to: Which route to take?. Can anyone shed some light on this issue and point me in the right direction?
What I understand:
You want a view to the left of an NSScrollView which scrolls vertically with the NSScrollView while ignoring horizontal scrolling.
You want a view below an NSScrollView which scrolls horizontally with the NSScrollView while ignoring vertical scrolling.
You want rulers.
To achieve this task:
Use 3 separate scroll views which do not overlap and donot inherit one another.
Activate rulers in whichever view(s) you would like them to appear.
Synchronize the scroll views (so that when one scrolls, the other scrolls accordingly).
How to synchronize scroll views is in the help. See User Experience > Controls > Scroll View Programming Guide for Mac > Synchronizing Scroll Views. This is also indirectly linked in the header of the help guide for NSScrollView.
If you want the three scroll views to be contained within an NSSplitView for resizing simplicity, then a fourth view must be added to consume the unused corner (good place to put controls). Since an NSSplitView can only be split vertically or horizontally, you will have to create an NSSplitView containing 2 split views with each of those split views containing 2 views that you actually see (splitting in one direction and then the other). The resizing of the split views will have to be synchronized in a manner much like the scrolling is synchronized to retain a straight cross of all four views.
As an example, I have 5 IBActions declared. When I push one, I want the other 4 to fall down off the screen. Any idea how to do this? Would I define a translation for each other IBAction??
A UIButton is a UIView. You can animate movement of a UIView; that movement can be to a position offscreen. (See the section under "animation" in the UIView class reference: http://developer.apple.com/library/ios/#documentation/uikit/reference/uiview_class/uiview/uiview.html) You might then want to remove the now-invisible buttons from their superview (in which case you'd need to retain them somehow or they might cease to exist), but you don't have to.
You will need a way to refer to the UIButtons. You can use IBOutlets for this, or you can "tag" the buttons in Interface Builder and use -[UIView viewWithTag:] to find the buttons you want to animate.
For a whole lot more on animation, see my book: http://www.apeth.com/iOSBook/ch17.html
I am wanting to implement history navigation in my app that mimics the slide away animation found in Safari on Lion and in XCode where a top view slides away at the speed of swipe to reveal the view underneath it.
I was looking for pointers on how to do this. I know how to detect the swipe. I assume I could implement the animation via a CALayer animation slide transition on the top view revealing a view underneath it. Has anybody else done this and can offer some further pointers?
It's a new NSEvent method, -trackSwipeEventWithOptions:.... You should call it from within your regular scroll/swipe event handler, whenever you decide the gesture should begin. Unfortunately it doesn't automatically handle the page animations — it just gives you updates with the gesture amount, and you have to do the animations yourself (using layers or views or somesuch). You'll probably want to save images of each page so you can animate them around during a gesture.
You see this in iPhone apps like Gilt. The user scrolls a view, and a subview apparently "sticks" to one edges as the rest of the scrollView slides underneath. That is, there is a text box (or whatever) in the scrollView, that as the scrollView hits the top of the view, then "sticks" there as the rest of the view continues to slide.
So, there are several issues. First, one can determine via "scrollViewDidScroll:" (during normal scrolling) when the view of interest is passing (or re-appearing). There is a fair amount of granularity here - the differences between delegate calls can be a hundred of points or more. That said, when you see the view approach the top of the scrollView, you turn on a second copy of the view statically displayed under the scrollView top. I have not coded this, but it seems like it will lack a real "stick" look - the view will first disappear then reappear.
Second, if one does a setContentOffset:animated, one does not get the delegate messages (Gilt does not do this). So, how do you get the callbacks in this case? Do you use KVO on "scroll.layer.presentationLayer.bounds" ?
Well, I found one way to do this. When the user scrolls by flicking and dragging, the UIScrollView gives its delegate a "scrollViewDidScroll:" message. You can look then to see if the scroller has moved the content to where you need to take some action.
When "sticking" the view, remove it from the scrollView, and then add it to the scrollView's superview (with an origin of 0,0). When unsticking, do the converse.
If you use the UIScrollView setContentOffset:animated:, it gets trickier. What I did was to subclass UIScrollView, use a flag to specify it was setContentOffset moving the offset, then start a fast running timer to monitor contentOffset.
I put the method that handles the math and sticking/unsticking the child view into this subclass. It looks pretty good.
Gilt uses a table view to accomplish this. Specifically, in the table view's delegate, these two methods:
– tableView:viewForHeaderInSection:
and – tableView:heightForHeaderInSection: