Slider set to continuous seems to block main thread - objective-c

I'm using a slider to resize some thumbnails in an app. I've set the slider to continuous so it updates as you move the slider instead of when you finish moving it. Works great, except for one thing:
The view that contains the thumbnails the slider resizes in in a split view. When the user starts sliding, i want to maximize said splitview for better usability. The only issue is, while the slider is being moved, it appears to be blocking any resizing operations of the UI. Anyone know how I can un-block it?
Or perhaps know of a different approach?

I figured it out!
Dragging the slider changes the run loop mode. I was maximizing my split view using an animation which has an NSTimer as it's backbone. I was adding the timer to the default run loop mode, when i should have been doing this:
[[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];

Related

GSAP slider, destroy timeline on resize and reinitialize

http://codepen.io/TPDBrendan/pen/xgwWwM
I'm trying to get a full page clip style slider set up to handle resize, but I seem to be going in circles at this point despite trying a bunch of suggestions on this topic from the forum.
I've already accomplished the basic effect - screen split in half vertically, each side has a timeline that is wiping towards the center revealing the slide below, which is simultaneously sliding towards center. Right side is on a slight delay intentionally. If you load the codepen and don't resize, you'll see what I mean.
Window resizing is throwing me a curveball, though. I've set up debounced functions to kill the 2 current timelines and then rebuild them again with new resized viewport dimensions. It's getting the new window dimensions and setting up a new timeline with these specs succesfully, but resizing several times reveals that it must not be killing the old timelines and is just creating multiple copies at each viewport size.
I'd like to be able to save the progress of the current timeline before destroying it and then initialize the new, resized timeline to this progress point so that to the user it just looks like one animation that pauses slightly on resize. Would also be great if, once the animation completes, window resize will not be able to initialize another timeline, so it can rest on the final slide. But, for now, just figuring out how to solve the current duplicate timelines issue would be awesome!
These are functions I'm using on resize, but kill doesn't seem to do anything.
function resizeLead(){
prog1 = tl.progress(),
prog2 = tl2.progress();
tl.seek(0).kill();
tl2.seek(0).kill();
}
function resizeTrail(){
windowSize[0] = $(window).width();
windowSize[1] = $(window).height();
buildTL();
}

Checking an SKNode is onscreen and visible

Is there a way to check when a SKSpriteNode / SKNode is onscreen (i.e. visible) I have a large scrolling background where I am spawning mobs, but I want to limit their animations and sounds if they are not visible. Is there a way to do this, I could write something in the update loop but I wanted to see if there was anything I could test before I start querying mob positions every frame?
I think you are doing this wrong. You should stick to the MVC pattern. As such, you only have data/points that are moving in a large area and in update method, if any data is within screen area, only would you draw them. If it is out, remove them.

How to make a UIButton auto blink?

Hi i am trying to make a uibutton to blink automatically. i am aware that there is a function "shows touch on highlight" which blink when user touch but i need my button to blink automatically. Is there any way to do it? Thanks!
First of all: Don't do that!!!
But if you do then you could
set timers or use performSelector ...withDelay: or similar stuff to trigger the switching of the images.
Or make the button transparent and layout it on top of a UIImageView. A UIImageView can be set up with an array of images, rather than a single image only, and a time interval used to swap from one image of the array to the next. See the docs for details. It is pretty straigt forward.

Lazy loading images in a UITableView that has a scroll index

I think this is a new spin on an old question, but I'm completely stuck here.
In my app, I have a UITableView with 650 cells, each with a custom 16x16 RGB icon. On most recent iOS devices, loading all of those icons into memory before displaying the table works totally fine, but on older hardware, I'd like to implement a lazy load system that only loads icons it needs.
I've implemented the Apple LazyTableImages example, (which uses a UIScrollView delegate to determine when the table stops moving to load the visible icons), but I've run into another snag.
My UITableView also has a section index display (ie the list of labels on the right hand side you can swipe up and down to scroll quickly), and the LazyTableImages example hasn't taken this into account.
If I scroll using the index, the images won't lazy-load. :(
As far as I can see, the scroll index doesn't actually have any delegate events it triggers.
So I'm wondering, has anyone else tried to implement lazy-loading on a table with a scroll index? Is there any way to track the index and find out if the user has interacted with it?
Thanks!
After buzzing around a few of my iOS developer buddies, I came up with a solution that worked well enough.
I set it up so that in addition to the icons being loaded from the UIScrollView delegates, an NSTimer object will periodically call a method that checks the currently visible table cells ([UITableView indexPathsForVisibleRows]) every .5 seconds, and loads any icons on the screen that haven't been loaded yet in a single separate thread.
I tried to make the solution as efficient as possible, so I made sure the timer was only active when the tableView was visible and stationary, and I liked it since it meant that every visible icon regardless was addressed.
One thing I discovered was that if the tableView was reloaded while the thread was looping through the visible cells (rare, but was possible), it would crash. The solution to this was to make sure each cell data source entry was retained while the icon was being loaded.

Cocoa - NSWindow animation when displayed?

How would I add some sort of CoreAnimation effect when showing a simple nswindow?
Thanks
I've done an animation like you describe before. However, it wasn't an easy task. Since your animation extends outside the bounds of the window itself, you'll need to render the animation in an oversized, transparent window. When the animation completes, you can order in the real window and remove the transparent one.
You'll need an image of the window to use as the content of your animation, so what I would do is order the window in (and probably make it the key window, too, so that it looks focused), but put it well off-screen so the user doesn't see it. Then use CGWindowListCreateImage to grab a screenshot of the window. Now you'll have what you need to create an animation.
After the animation completes, just order the real window over top of the transparent one, then remove the transparent window. Getting the math right so that the image of the window in the animation and the real window is a bit tricky, but it's definitely doable.