Question

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?

Était-ce utile?

La solution

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.

Autres conseils

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top