简体   繁体   English

在ios中创建用户可配置的UI

[英]Creating a user configurable UI in ios

I'm writing an app in which there will be user defined "categories" which will consist of a label and each category will have a user defined list of "items" which will be UIButtons. 我正在编写一个应用程序,其中将有一个由标签组成的用户定义的“类别”,并且每个类别都将具有一个由用户定义的“项目”列表,即UIButtons。 I want a user to be able to layout the user interface to their choosing. 我希望用户能够根据自己的选择来布局用户界面。 What's the best way to implement this? 实现此目的的最佳方法是什么? Any example code out there? 有任何示例代码吗?

Edit: Just to make myself clear, I have groups of buttons with a group "heading". 编辑:为了使自己更清楚,我有一组带有“标题”的按钮。 I'd like users to be able to move these buttons around inside a group and also to arrange the groups as a whole. 我希望用户能够将这些按钮在组内移动,也可以将组整体布置。 It's okay if they have to enter some sort of "edit mode" to move things around. 如果他们必须进入某种“编辑模式”来移动内容,那也没关系。

Probably the easiest way is to use editable UITableViews with UITableViewStyleGrouped style (just like Settings.app). 可能最简单的方法是使用具有UITableViewStyleGrouped样式的可编辑UITableViews(就像Settings.app一样)。 Then you can add, remove and arrange items inside groups. 然后,您可以在组内添加,删除和排列项目。 You can show it as "edit mode" view. 您可以将其显示为“编辑模式”视图。

Here are some useful posts about it: 这是一些有用的帖子:

You could use touch handling methods to enable drag-drop type of rearranging of buttons. 您可以使用触摸处理方法来启用拖放式按钮的重新排列。 UIPanGestureRecognizer is a useful class for this. UIPanGestureRecognizer是对此有用的类。 A reference for this can be found here. 可以在此处找到对此的参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM