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

好久不见. 提交于 2019-12-06 08:49:39

问题


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

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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/7848805/how-do-i-add-a-button-to-the-inappsettingskit-setting-view-iphone-ipad

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