3

How can I make the buttons in an application draggable and droppable just like in OS' home screen?

So far I see two ways to animate stuff –

  1. By UIView methods which provide animation for frame, bounds, centre, transform and alpha
  2. By using Core Animation, which I'm not familiar with.

I was able to move a UIImageView object. Will the same apply for moving a UIButton object?

My code for moving a UIImageView object is:

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [[event allTouches] anyObject];
    CGPoint location = [touch locationInView:touch.view];
    imageView.center = location;
}

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    [self touchesBegan:touches withEvent:event];
}

Can I use this same code for moving the button?

Deepak Danduprolu
  • 44,595
  • 12
  • 101
  • 105
Krishnachandra Sharma
  • 1,332
  • 2
  • 20
  • 42

2 Answers2

0

look at this post to start with iPhone drag/drop

and this Basic Drag and Drop in iOS

Community
  • 1
  • 1
chewy
  • 8,207
  • 6
  • 42
  • 70
0

If you mean something similar to the facebook launcher screen, which has arrangeable icons, i recommending taking a look on the three20 framework (which powers the facebook iphone app): http://three20.info

The TTLauncherView (http://three20.info/showcase/launcher) supports reordering and deletion of items, custom column and row counts, and multiple pages of content. It also works on the iPad.

It's amazing how much time it can save you. It's mostly bug-free and ready to use.

aporat
  • 5,922
  • 5
  • 32
  • 54