【问题标题】:Making buttons able to be dragged and dropped使按钮可以拖放
【发布时间】:2011-09-21 05:45:03
【问题描述】:

如何使应用程序中的按钮像操作系统主屏幕一样可拖放?

到目前为止,我看到了两种制作动画的方法——

  1. 通过UIView方法为frameboundscentretransformalpha提供动画
  2. 使用我不熟悉的Core Animation

我能够移动UIImageView 对象。这同样适用于移动UIButton 对象吗?

我移动 UIImageView 对象的代码是:

-(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];
}

我可以使用相同的代码来移动按钮吗?

【问题讨论】:

    标签: objective-c ios cocoa-touch ios4 core-animation


    【解决方案1】:

    如果您的意思类似于具有可排列图标的 facebook 启动器屏幕,我建议您看一下 three20 框架(它为 facebook iphone 应用程序提供动力): http://three20.info

    TTLauncherView (http://three20.info/showcase/launcher) 支持重新排序和删除项目、自定义列和行计数以及多页内容。它也适用于 iPad。

    它可以为您节省多少时间,真是令人惊讶。它几乎没有错误并且可以立即使用。

    【讨论】:

    • 哇...太好了..感谢您的支持。你的回答有帮助。
    • 我的程序为 UIImageView 运行。但是我可以使用相同的代码来移动圆形矩形按钮吗? ——
    【解决方案2】:

    先看这篇文章 iPhone drag/drop

    还有这个 Basic Drag and Drop in iOS

    【讨论】:

    • 我的程序为 UIImageView 运行。但是我可以使用相同的代码来移动圆形矩形按钮吗??
    猜你喜欢
    • 1970-01-01
    • 2018-11-21
    • 2020-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多