简体   繁体   English

是否有用于在iPhone应用程序中设置首选项的库或框架?

[英]Is there a library or framework for setting preferences from within an iPhone application?

Using the Settings.app on the iPhone isn't that hard. 使用iPhone上的Settings.app并不难。 In fact Xcode does the most of the work for you. 事实上,Xcode为您完成了大部分工作。 Just add the Settings.bundle to your project and there you have it for nearly no cost. 只需将Settings.bundle添加到您的项目中即可,几乎不需要任何费用。

At the moment I'm developing an application for the iPhone which requires the user to fill out several "forms", mostly key-value pairs, some sliders and several modal views with "dropdown" menus. 目前我正在为iPhone开发一个应用程序,要求用户填写几个“表单”,主要是键值对,一些滑块和几个带有“下拉”菜单的模态视图。 So similar the task is similar to what the Settings.app does. 如此相似的任务类似于Settings.app所做的。

Doing the forms by myself is a heavy task in my opinion, so I'm wonding if there's a framework for this kind of tasks. 在我看来,自己做表格是一项繁重的任务,所以我想知道是否有这种任务的框架。 Unfortunately it looks like Apple doesn't provide it's own solution. 不幸的是,Apple似乎没有提供自己的解决方案。 Perhaps somebody knows of a framework or an article on the web which describes best practices. 也许有人知道网络上描述最佳实践的框架或文章。

In case you don't understand to which pattern I'm referring, I made a screenshot: http://img.skitch.com/20090625-s8bf6ahybwe3cesd1id38h3nt.jpg 如果您不了解我所指的模式,我制作了截图: http//img.skitch.com/20090625-s8bf6ahybwe3cesd1id38h3nt.jpg

Check out http://www.inappsettingskit.com . 查看http://www.inappsettingskit.com It's used in a couple of apps and it's actively maintained (by myself and a bunch of others). 它被用在几个应用程序中并且它被积极维护(由我自己和其他一些人)。

After much research I didn't manage to get a good answer to my initial question. 经过大量研究后,我无法对我最初的问题得到很好的答案。 But by now I stumbled over this repository on github: mySettings 但到现在为止,我在github: mySettings上偶然发现了这个存储库

It's better to put settings in the app, at least until Apple makes it easy to send the user out to Settings and then back into the app. 最好将设置放在应用程序中,至少在Apple可以轻松将用户发送到“设置”然后再返回应用程序之前。 If you look at the new 3.0 UITableViewCellStyles, there's one style tailor-made to doing settings kind of cells - it would make it pretty easy to build out a simple settings screen. 如果你看一下新的3.0 UITableViewCellStyles,有一种风格是为设置类型的单元格而量身定做的 - 它可以很容易地构建一个简单的设置屏幕。

Well if you are doing settings then I would suggest putting them in the correct place and using the Settings.bundle. 好吧,如果您正在进行设置,那么我建议将它们放在正确的位置并使用Settings.bundle。

I guess you are doing settings though that are highly important to you app and it would be a horrible user experience if they had to keep jumping from the app to settings and back again. 我猜你正在进行设置,虽然这对你的应用程序非常重要,如果他们不得不继续从应用程序跳转到设置并再次返回,那将是一个糟糕的用户体验。

When you say doing the task is heavy - can you elaborate - as I have done it and it has not been heavy. 当你说任务很重要时 - 你能否详细说明 - 正如我所做的那样并且它并不重。

Use a UITableViewController 使用UITableViewController

for each cell that you want to use put in code similar to: 对于您要使用的每个单元格,请输入类似于以下内容的代码:

        cell.textLabel.text = @"Last name:";
        UIFont *labelFont = [UIFont systemFontOfSize:[UIFont labelFontSize]];
        CGSize textSize = [cell.textLabel.text sizeWithFont:labelFont];
        baseRect.origin.x = textSize.width+15;
        baseRect.origin.y +=7;
        baseRect.size.width = baseRect.size.width - textSize.width - 15;
        baseRect.size.height = 23;
        UITextField *textField = [[UITextField alloc] initWithFrame:baseRect];
        textField.keyboardType = UIKeyboardTypeAlphabet;
        textField.returnKeyType = UIReturnKeyDone;
        textField.clearButtonMode = UITextFieldViewModeWhileEditing;
        textField.delegate = self;
        textField.placeholder = @"last name";
        [textField addTarget:self action:@selector(lastNameChanged:) forControlEvents:UIControlEventAllEditingEvents];
        textField.tag = 182;
        [cell.contentView addSubview:textField];    
        [textField release];

This has worked for me to reproduce the interface you are talking about - the example here is a TextField - but the same code has worked very well with all controls. 这对我来说重现了你正在谈论的界面 - 这里的例子是一个TextField - 但是相同的代码对所有控件都运行良好。

I am pretty sure what he is asking for is a framework that recreates the settings interface from the settings.bundle file so that there can be settings both in the settings app and within your app. 我很确定他要求的是一个从settings.bundle文件重新创建设置界面的框架,以便在设置应用程序和应用程序中都可以进行设置。

I don't yet know of anything like that but, I could really use one and I have considered writing one. 我还不知道那样的东西,但我真的可以用一个而且我考虑过写一个。

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

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