iPhone Xcode - 第二个xib视图上的导航控制器?

时间:2010-04-13 15:29:24

标签: iphone xcode

一切都很好,我的导航控制器显示的是我的'菜单1'项目,但当我点击它时,似乎有一个问题:

[self.navigationController pushViewController:c animated:YES];它没有连接到myClass文件中的断点。所以我想我没有加入什么?但不确定是什么?

我使用导航控制器的第二个视图无法直接访问AppDelegate,因此无法像我在某些教程中看到的那样加入它。

第一个视图只是点击通话时的按钮:

[self presentModalViewController:mainViewController animated:YES];

我的第二个View'MainViewController'标题如下:

@interface MainViewController :UITableViewController <UITableViewDelegate, UITableViewDataSource>
{
    NSArray *controllers;
    UINavigationController *navController;
}

@property (nonatomic, retain) IBOutlet UINavigationController *navControllers;

@property (nonatomic, retain) NSArray *controller;

然后我有我的MainViewController.m

@synthesize controllers;
@synthesize navController;

- (void) viewDidLoad
{
    NSMutableArray *array = [[NSMutaleArray alloc] init];
    myClass *c = [[myClass alloc] initWithStyle:UITableViewStylePlain];
    c.Title = @"Menu 1";

    [array addObject:c];
    self.Controllers = array;
    [array release];
}

实现了numberOfRowsInSection和cellForRowAtIndexPath

- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    NSUInteger row = [indexPath row];
    myClass *c = [self.controllers objectAtIndex:row];
    [self.navigationController pushViewController:c animated:YES]; // doesn't load myClass c
    // [self.navController pushViewController:c animated:YES];
}

同样在Interface Builder中,我将导航控制器拖到我的新XIB上,并将Root View Controller类更改为MainViewController,并将文件所有者连接器连接到导航控制器以连接navController Outlet。

谢谢你的时间。

1 个答案:

答案 0 :(得分:0)

myClass.h

#import "SecondLevelViewController.h" //This inherts UITableViewController

@class myClass;

@interface myClass : SecondLevelViewController
{
NSArray *list;
myClassDetail *detail;
}
@property (nonatomic, retain) NSArray *list;

myClass.m

#import "myClass.h"
#import "myClassDetail.h"
#import "NavAppDelegate.h"

@implementation myClass
@systjesize list;

- (void) viewDidLoad
{
  NSArray *array = [[NSArray alloc] initWithObjects:@"test1",@"test2",nil];
self.list = array;
.. .. ..
//I can't get a break point at this point or in any of the other methods
}

因此,在此页面中没有得到突破点告诉我,我已经错过了一些。由于这是MainWindow.XIB中的单独XIB文件,因此我无权访问App Delegate。

当我在界面构建器中没有App委托时,我真的需要知道如何将Navigation Controller连接到第二个视图XIB文件。所有教程都显示导航控制器已连接到此应用程序委托。

程序符合文件并运行,我在列表中获得第一个“菜单1”,但是当我尝试使用我的新myClass菜单项“test 1”,“test 2”重新填充相同的导航列表时 它没有命中事件viewDidLoad。