新的 UIView 未加载

发布于 2024-10-22 06:23:53 字数 890 浏览 1 评论 0原文

我有一个 TabController 视图设置,我正在尝试在当前选项卡中加载新视图。该视图将根据 UIAlertView 中的选择进行加载。

因此,我有以下代码尝试这样做:

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex{

    // Yes Button
    if (buttonIndex == 0) {

        NSLog(@"%@ Pressed", [alertView buttonTitleAtIndex:0]);

        user = [[UserInfo alloc] initWithNibName:@"UserInfo"  bundle:nil];
        [self.navigationController pushViewController:user animated:YES];

        [user release];
    }
    // Don't show again Button
    if (buttonIndex == 1) { 
        NSLog(@"%@ Pressed", [alertView buttonTitleAtIndex:1]);
    }

    // No Button
    if (buttonIndex == 2) {
        NSLog(@"%@ Pressed", [alertView buttonTitleAtIndex:2]);
    }
}

“是”块打印到控制台,但是新视图不会加载。 User 是 UserInfo 的实例,而 UserInfo 又是 UIViewController 的子类。 Nib UserInfo 已创建并且是项目的一部分。

我缺少什么?

I have a TabController View setup and I am attempting to load a new view in the current tab. This view would be loaded depending on a selection from a UIAlertView.

As such I have this code attempting to do so:

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex{

    // Yes Button
    if (buttonIndex == 0) {

        NSLog(@"%@ Pressed", [alertView buttonTitleAtIndex:0]);

        user = [[UserInfo alloc] initWithNibName:@"UserInfo"  bundle:nil];
        [self.navigationController pushViewController:user animated:YES];

        [user release];
    }
    // Don't show again Button
    if (buttonIndex == 1) { 
        NSLog(@"%@ Pressed", [alertView buttonTitleAtIndex:1]);
    }

    // No Button
    if (buttonIndex == 2) {
        NSLog(@"%@ Pressed", [alertView buttonTitleAtIndex:2]);
    }
}

The Yes block prints out to the console, however the new view does not load. User is an instance of UserInfo, which in turn is a subclass of UIViewController. The Nib UserInfo is created and is part of the project.

What am I missing?

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

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

发布评论

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

评论(2

回忆躺在深渊里 2024-10-29 06:23:53

这两行是不必要的:

[user.view setHidden:NO];
[self.navigationController setView:user.view];

但这一行是:

[user release];

您如何设置标签栏控制器?您是否将此视图放置在 UINavigationController 中,然后将该导航控制器添加到 TabBarController 中?

请查看 iOS 视图控制器编程指南(特别是组合 ViewController 接口部分)并验证您是否正确嵌套了这些视图。

These two lines are unnecessary:

[user.view setHidden:NO];
[self.navigationController setView:user.view];

But this one is:

[user release];

How are you setting up your tab bar controller? Have you placed this view inside of a UINavigationController then added that navigation controller to the TabBarController?

Please review the View Controller Programming Guide for iOS (specifically the Combined ViewController Interfaces section) and verify you are nesting these views correctly.

z祗昰~ 2024-10-29 06:23:53

user 是全局变量吗?我通常会看到类似的东西
UserInfo *user = [[UserInfo alloc] initWithNibName:@“UserInfo”bundle:nil];

作为模式。由于导航控制器实际上将成为视图的主要所有者

Is user a global variable? I usually see something like
UserInfo *user = [[UserInfo alloc] initWithNibName:@"UserInfo" bundle:nil];

as the pattern. Since the navigation controller is really going to be the main owner of the view

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