开发者

Making buttons able to be dragged and dropped

开发者 https://www.devze.com 2023-03-15 03:00 出处:网络
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 –

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 movi开发者_如何学JAVAng 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?


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.


look at this post to start with iPhone drag/drop

and this Basic Drag and Drop in iOS

0

精彩评论

暂无评论...
验证码 换一张
取 消