【问题标题】:MainViewController (storyboard) can not push my UITableViewControllerMainViewController(故事板)无法推送我的 UITableViewController
【发布时间】:2012-02-11 16:05:22
【问题描述】:

我刚刚在 xcode 4.2 中使用模板实用程序应用程序创建了一个新项目。这是我的项目层次结构:

然后,我尝试从 MainViewController 推送不带 XIB 文件的 UITableViewController (Batikla : UITableViewController)。 首先,我在 MainViewController 故事板中放置了一个按钮并将其连接到我的 ibaction 方法:

@implementation MainViewController
@synthesize managedObjectContext = _managedObjectContext;
@synthesize flipsidePopoverController = _flipsidePopoverController;

    - (IBAction)batikla{
        NSLog(@"test 1");

        Batikla *batikla = [[Batikla alloc] initWithStyle:UITableViewStylePlain];
        batikla.title = [NSString stringWithFormat:@"Test"];
        [self.navigationController pushViewController:batikla animated:YES];
        [batikla release];

        NSLog(@"test 2");

}

点击按钮后没有视图推送到视图,而是在控制台中出现:

There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".Attaching to process 58916.
2012-01-17 01:30:47.569 iBadah[58916:207] test 1
2012-01-17 01:30:47.572 iBadah[58916:207] test 2

方法被触发了,但为什么我的 uitableviewcontroller 没有被推到屏幕上?

【问题讨论】:

    标签: ios5 xcode4.2 uitableview storyboard


    【解决方案1】:

    推送和弹出需要导航控制器。该实用程序模板不包含导航控制器。

    【讨论】:

    • 如何将导航控制器放入情节提要中?我去编辑器->嵌入->导航控制器然后运行它,我得到这样的错误:[UINavigationController setManagedObjectContext:]: unrecognized selector sent to instance 0x6a20820.我在这里错过了什么?
    【解决方案2】:

    是的,我明白了.. TJ 是仪式,我在这里缺少导航控制器 所以这里是: 在 AppDelegate.m didFinishLaunchingWithOptions 中,我注释掉了默认代码,并放入了导航视图控制器,检查一下:(因为我使用了实用程序模板,我假设你也得到了相同的代码)

    // Override point for customization after application launch.
        UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
        MainViewController *controller = (MainViewController *)navigationController.topViewController;
        //MainViewController *controller = (MainViewController *)self.window.rootViewController;
        controller.managedObjectContext = self.managedObjectContext;
        return YES;
    

    别忘了在故事板中添加 uinavcontroller,你可以从 --> 编辑器 -> 嵌入 -> 导航控制器(点击主视图控制器后),像这样: 你很高兴去那里。

    希望这对某人有所帮助。 谢谢

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-12-12
      • 2019-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-25
      • 2013-10-10
      相关资源
      最近更新 更多