如何允许用户通过iOS sdk移动按钮 [英] How to allow a user to move a button via iOS sdk

查看:121
本文介绍了如何允许用户通过iOS sdk移动按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用我的应用做一些新功能。

I'm trying to do something new with my app.

我有很多按钮,我希望用户能够通过拖动它们在屏幕上重新排列。该视图目前通过Interface Builder创建。理想的实现将检查NSUserDefaults中的标志,如果存在该标志将允许用户移动对象,删除它,然后移除标志,这将保存下次用户加载时的设置。

I have a number of buttons that I'd like the user to be able to rearrange on the screen by dragging them. The view is currently created via Interface Builder. The ideal implementation would check for a flag in NSUserDefaults which if present would allow the user to move the object, drop it,then remove the flag which would save the setup for next time the user loads.

任何人都知道这样的事情是否可行?

Anyone know if anything like this would be possible?

推荐答案

你可以使用动作方法完成它 -

You can have it done by using the action method -

//在拖动事件期间调用每个实例

//called on each instance during a drag event

- (IBAction)draggedOut: (id)sender withEvent: (UIEvent *) event {
    UIButton *selected = (UIButton *)sender;
    selected.center = [[[event allTouches] anyObject] locationInView:self.view];
} 

这篇关于如何允许用户通过iOS sdk移动按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆