如何将按钮添加到 InAppSettingsKit 设置视图 (iPhone/iPad)?

发布于 2024-12-10 22:20:07 字数 203 浏览 0 评论 0原文

我一直在查看 InAppSettingsKit 提供的示例应用程序,我注意到使用了几个按钮:

在此处输入图像描述

我想在我的应用程序中集成一个名为“重置”的红色按钮,但我不知道该怎么做。我查看了示例应用程序中的代码,但我对这一切有点迷失。请问有人可以帮我吗?

I have been looking at the sample app provided by InAppSettingsKit and I noticed the use of a couple of buttons:

enter image description here

I would like to integrate a single red button in my app called reset, however I'm not sure how to do it. I've had a look at the code in the sample app and I'm a bit lost with it all. Please could someone help me out?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我不会写诗 2024-12-17 22:20:07

在花了一段时间搜索所有代码和 plist 后,我​​设法找到了我的问题的答案。对于那些感兴趣的人,您需要执行以下操作:

  1. 在 Root.plist 文件中添加一行,并将 Type 设置为 IASKButtonSpecifier
  2. 将此行上的标识符设置为有用的内容,例如“myButton1”。
  3. 将以下委托方法添加到您从中加载 InAppSettingsKit 的 viewController:

    - (void)settingsViewController:(IASKAppSettingsViewController*)发送者按钮TappedForKey:(NSString*)key 
    {
        if ([key isEqualToString:@"myButton1"]) 
        {
           // 执行一些操作...
        }
    }
    

值得注意的是,该键等于您在 Root.plist 中设置的标识符。

我唯一还没弄清楚的是如何改变按钮的颜色;但是我怀疑这可以通过重写方法来实现。

After spending a while searching through all the code and plists I managed to find the answer to my question. For those who are interested what you need to do is the following:

  1. Add a row to your Root.plist file with the Type set to IASKButtonSpecifier.
  2. Set the Identifier on this row as something useful e.g. 'myButton1'.
  3. Add the following delegate method to the viewController you loaded the InAppSettingsKit from:

    - (void)settingsViewController:(IASKAppSettingsViewController*)sender buttonTappedForKey:(NSString*)key 
    {
        if ([key isEqualToString:@"myButton1"]) 
        {
           // Do some actions...
        }
    }
    

It's worth noting that the key is equal to the identifier you set in the Root.plist.

The only thing I haven't worked out yet is how to change the colour of the button; however I suspect this may be possible by overriding a method.

剧终人散尽 2024-12-17 22:20:07

很高兴您已经找到了部分解决方案。要自定义外观,您应该使用 http://www 上记录的 IASKCustomViewSpecifier 创建自定义视图.inappsettingskit.com/。例如,黄色图标就利用了这一点。在您的情况下,您可以返回具有红色背景颜色(或自定义背景图像)的 UIButton 实例。

在这种情况下,您不需要 buttonTappedForKey 方法来获取点击事件,而是像往常一样配置按钮的目标/操作。

Great that you already found part of the solution. To customize the look, you should create a custom view using the IASKCustomViewSpecifier documented on http://www.inappsettingskit.com/. The yellow icon for instance is making use of this. In your case, you could return an instance of UIButton with a red background color (or a custom background image).

In this case, you don't need the buttonTappedForKey method to get the tap event but configure the target/action of your button as usual.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文