简体   繁体   中英

What is the proper way to set a delegate for a InAppSettingsKit view controller without subclassing

I need to create a IASKSettingsDelegate to respond to settingsViewControllerDidEnd in a StoryBoard setting. I have made AppDelegate implement that delegate protocol (it was an idea) but I can't seem to figure out how to connect it as the delegate of my IASKAppSettingsViewController without subclassing it.

If this is not possible or is not the right way to get settingsViewControllerDidEnd answered, I welcome suggestions.

You can set the delegate in -prepareForSegue:sender: of the calling view controller. Assuming your segue identifier is named "settings":

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"settings"]) {
        IASKAppSettingsViewController *settingsViewController = segue.destinationViewController;
        settingsViewController.delegate = self;
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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