I am working on cocoa for 1 month. I am working on application where I need to have my own custom week view, which is more compact then ical, but what I want is the nice scrolling animation which ical gives when we move from one week to another.
Currently I am using NSView Animation, having two views, one is buffer view and one is main view. What i do is before animation i put buffer view in the right position then simply changes the both views, frame origin to get the animation effect. So far it does the job but doesn't seems to be as good as ical.
I tried core graphics but couldn't able to get the same scrolling effect which ical gives.
Related
I have a SCNView which is the main view for the ViewController in my storyboard. It also has some child views, like buttons.
I set one of these buttons to present a popover. However, as long as the popover is presented above the SCNView, rendering of the scene is slowed down (I understand that it's probably to save battery and provide smooth interaction with the popover).
For my application however, this looks pretty bad. I haven't unfortunately found any setting for this. Is there a way to force the view to render at full speed even when it's partially overlayed?
I target the iOS version 8.0.
I have a question. I'm writing an app where in one of its views I want to achieve the next:
the view itself doesnt rotate meaning all the controls etc are pinned to their places BUT the objects (buttons for example) DO rotate on their place place.
The problem is that Autorotate is either rotates everything, including position change of the buttons, or locks everything including keeping button orientation.
From what I understood I can lock the view and do a manual transform every time orientation changes but it seems to me very long and ugly, when Xcode has now all this Autolayout and class sizes etc ...
Is there a more elegant way to do it ?
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.
Although I know of a solution to this problem, I am interested if someone can explain this solution to me. I also wanted to get this out there because I could not find any mention of this problem online, and it took me several hours over several days to track down. I have an NSTableView behaving strangely regarding redraws and its selection. The problem looks like this:
Table contents fades in, instead of appearing instantly upon it's appearance on screen. When scrolling through the contents, the newly appearing rows also fade in. When you make a selection (single or multiple), and scroll it off screen, then make another selection (that should replace, not add-to first selection), the first selection does not get cleared properly. If you scroll back to it, it is still there, in addition to your new selection. This is a display-update problem, not selection problem - i.e. your new selection is valid, it is just displayed wrong.
I tracked this through the NSArrayController I was binding to, the underlying Array, sorting, all the connections, and settings, etc., but all that has nothing to do with it.
What solved the problem was:
In the View Effects (right-most) Inspector, uncheck "Core Animation Layer" for the Window's main view.
Can anyone explain what is happening here, and perhaps improve upon the solution ?
It looks like Core Animation and NSTableView aren't getting along so well. The "fading" effect is a by-product of the way core animation works. When you have core animation in one view, it is also enabled in all of that view's subviews.
I don't recommend using core animation on the Mac unless absolutely necessary, because some interface elements (NSTextView and NSTableView, for example) aren't compatible with it. iOS has much better support for table views and such using core animation, mainly because it was designed with core animation in mind.
I know that some more simple UI elements are compatible (NSTextField and NSButton, for example).
If you absolutely need core animation in the rest of the window, put all the other views in a subview of the content view, while leaving the table view directly in the content view. You can then enable Core Animation in the other view.
Commenters, feel free to add to the list of what is and isn't compatible.
Unfortunately this is hard for me to test myself because I have yet to get a Magic Mouse of my own, but I've been told by my testers who do have a magic mouse that momentum scrolling isn't working in my app. I've not subclassed NSScrollView, but scrollview's document view is all custom. I have not overridden scrollWheel: anywhere, either, and yet momentum apparently just isn't working. I'm not even sure where to begin. I thought it'd just send scrollWheel events and things would take care of themselves. (Scrolling with a wheel or on the MBP trackpad works as expected.) Obviously I must somehow be doing something that's stopping it, but I don't even know where to begin. Thoughts?
I figured this out awhile ago and the problem was that on scroll, I was doing a lot of fancy view manipulation somewhat like how on the iPhone the UITableView adds and removes views as they scroll on and off screen. This worked great for performance - but the more I got into OSX programming, the more I realized this was wrong for OSX (but the right idea of iPhone).
Anyway, what's really going on, it seems, is that when you do something like a wheel scroll, the scroll event is sent to the view that's under the mouse cursor and then it ripples down the responders/views until it gets somewhere that handles it. Normally this isn't a problem, but with momentum scrolling the OS is really just sending ever smaller scrollWheel events to the view that was under the cursor at the time the momentum started. That means if the view is removed during the course of scrolling (because it scrolls off screen or something), it breaks the chain and the momentum stops because the view that's still getting the scrollWheel messages is no longer in the view hierarchy.
The "simple" fix is to not remove the view that got the last scrollWheel event - even if it's off screen. The better fix (and the one I went with) is to not try to use NSViews like they are UIViews and instead just draw the content using drawRect. :) Not only is that about a billion times faster, it Just Works(tm) with momentum scrolling because it's how OSX expects things to be done.
Repeat after me: OSX is not iPhoneOS.. :P
Odd scrolling behavior can occur when you don't set the Line Scroll and Page Scroll properties of the NSScrollView itself.
Beyond that, you're quite simply going to have to get a Magic Mouse - easily said or not :-) - to test this yourself or post the entire code of your custom view as well as the xib containing it. There's no way others can offer you more than guesses (like the above) without it.