How do I add a button to the InAppSettingsKit setting view (iPhone/iPad)?

我是研究僧i 提交于 2019-12-04 14:22:26

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!