子类化 IASKAppSettingsViewController

发布于 2024-11-15 01:32:37 字数 1359 浏览 3 评论 0原文

我正在尝试调整默认 IASKAppSettingsViewController 的行为,以便它可以为自定义视图(type = IASKCustomViewSpecifier)提供自定义子视图控制器(对于 type = PSChildPaneSpecifier)。

我尝试对 IASKAppSettingsViewController 进行子类化,而不向代码添加任何新功能。

然而,当我加载自己的子类时,设置视图完全是空的 - 即使对于一个裸子类也是如此。当我切换回默认的 IASKAppSettingsViewController 时,一切都会按预期再次工作。

我尝试在子类的不同位置设置断点,一切似乎都工作正常 - 除了没有显示任何内容。

我尝试在文档中寻找线索,但似乎找不到任何解释原因的内容。 InAppSettingsKit 的文档甚至指出它是为子类化而设计的。

我在这里缺少什么?任何线索都值得赞赏 - 或者更好的是为傻瓜提供一个小的分步指南。

更新代码:

设置翻转视图。它适用于标准 IASKAppSettingsViewController 但因我的空派生 MyCustomSettingsViewController 而失败

- (IBAction)showInfo:(id)sender
{    
    // Setup navigation controller for settings view
    MyCustomSettingsViewController *settings = [[MyCustomSettingsViewController alloc] init];
    //IASKAppSettingsViewController *settings = [[IASKAppSettingsViewController alloc] init];
    settings.delegate = self;
    settings.showDoneButton = YES;
    UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:settings];
    navigation.navigationBar.barStyle = UIBarStyleBlack;
    [settings release];

    // Display the settings
    navigation.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:navigation animated:YES];
    [navigation release];
}

I'm trying to tweak the behavior of the default IASKAppSettingsViewController so it can provide custom subviewcontrollers (as for type = PSChildPaneSpecifier) for custom views (type = IASKCustomViewSpecifier).

I've tried to subclass IASKAppSettingsViewController without adding any new functionality to the code.

However when I load up my own subclass the settings view is completely empty - even for a bare subclass. When I switch back to the default IASKAppSettingsViewController everything works again as expected.

I've tried setting breakpoints various places in my subclass and everything seems to be working fine - except that nothing is displayed.

I've tried looking for clues in the documentation, but can't seem to find anything that explains why. The documentation for InAppSettingsKit even states that it's designed for subclassing.

What am I missing here? Any clues are appreciated - or even better a small step-by-step guide for dummies.

Updated with code:

Setting up the flipside view. It works with the standard IASKAppSettingsViewController but fails with my empty derived MyCustomSettingsViewController

- (IBAction)showInfo:(id)sender
{    
    // Setup navigation controller for settings view
    MyCustomSettingsViewController *settings = [[MyCustomSettingsViewController alloc] init];
    //IASKAppSettingsViewController *settings = [[IASKAppSettingsViewController alloc] init];
    settings.delegate = self;
    settings.showDoneButton = YES;
    UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:settings];
    navigation.navigationBar.barStyle = UIBarStyleBlack;
    [settings release];

    // Display the settings
    navigation.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:navigation animated:YES];
    [navigation release];
}

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

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

发布评论

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

评论(2

南巷近海 2024-11-22 01:32:37

尝试将此方法添加到您的子类中:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    return [super initWithNibName:@"IASKAppSettingsView" bundle:nibBundleOrNil];
}

如果您不这样做,IASKAppSettingsViewController 的默认实现将启动,并尝试查找以您的类名命名的笔尖,在本例中为“MyCustomSettingsViewController”。笔尖”。这可能不存在。

发生这种情况是因为 -init 的默认实现调用 -initWithNibName:nil bundle:nilnil 作为文件名意味着搜索默认笔尖。

Try to add this method to your subclass:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    return [super initWithNibName:@"IASKAppSettingsView" bundle:nibBundleOrNil];
}

If you don't do that, the default implementation of IASKAppSettingsViewController kicks in and it tries to find a nib named after your class name, in this case "MyCustomSettingsViewController.nib". This probably doesn't exist.

This happens because the default implementation of -init calls -initWithNibName:nil bundle:nil and nil as the filename means to search for a default nib.

陈甜 2024-11-22 01:32:37

尝试在初始化步骤上设置断点,如果您将其添加为子视图/推送导航控制器。对每个方法使用 NSLogs,以便您可以找到问题。如果没有任何效果,请向我发送代码(使用 IASKAppSettingsViewController 创建演示代码)来重现问题,然后我将调查该问题。

Try setting breakpoint on initialization steps and if you are adding that as a subview/ pushing on navigation controller. Use NSLogs for each method so you can find the issue. If nothing works send me the code (create a demo code using IASKAppSettingsViewController) to recerate the problem then I'll look into the issue.

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