Need help?

I'm available for remote short term contracting or consultancy work. Please check out my LinkedIn profile for more details on my experience.

Please feel free to use the form below to contact me.



View

If you're trying to programmatically figure out how to move or drag a view with your finger, then read on.

I was looking for a solution to this problem just the other day, and couldn't really find that much. What I needed was a view that you could move with your finger, and upon lifting the finger, it would snap into place at a set location. Seeing as I couldn't find anything like this, I decided to write my own custom view, which did just that.

The view I wrote extends UIImageView, but you can change that to UIView if you want. So how does this work you ask? Well, it basically takes a topLock, bottomLock, and whether it's moving on the x axis or not (if not, then it uses the y axis). The top lock is the x(or y) point where the view will lock into place, and same with the bottom lock. And how that works is that it'll check which one is closest, and lock it into that spot. So here's an example, if you drag the view up on the y axis all the way to the top and let go, it'll move it to the closest lock point (which will most likely be the top lock. This will also give that nice swing-back (gravity) effect that you see on the iPhone tableviews.

jon | June 07, 2010 | Comments (2)

Have you seen other applications with Buttons (or other views, but mainly Buttons) that stay in one spot, even if you're scrolling through a list? These are commonly known as floating Buttons or Views.

This is actually used a lot on websites as well, and they may seem hard to produce at first glance, but it's actual quite easy.

I'll run you through an easy application that uses one floating button within a ListActivity, which is aligned to the bottom right of the screen - on top of the ListView.

jon | June 07, 2010 | Comments (6)