我对iOS相当陌生,我试图在iPad应用程序的钻取例程中显示来自另一个tableView控制器的tableView控制器。然而,新的tableView不会显示。我可以在调试模式下通过以下例程遵循程序逻辑,但在此逻辑之后,相同的视图仍保留在屏幕上。我设置断点在新的表视图程序显示,他们从来没有达到。我已经在这个程序的应用文件中包含了HEDView.h
,不知道为什么没有显示新的视图。对于更多信息的任何帮助或建议都是感激的。
下面是调用tableView的例程:HEDView将不显示
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here. Create and push another view controller.
[tableView deselectRowAtIndexPath:indexPath animated:NO];
HEDView *detailViewController = [[HEDView alloc] initWithNibName:@"HEDView" bundle:nil];
// Pass the selected object to the new view controller.
detailViewController.title = @"HEDView";
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
}
如果你的要求是导航到其他视图控制器时,在行中的单元格被选中,那么我认为你的navigationcontroller没有正确分配。在调试时检查self。navigationController返回正确的地址。如果没有,那么你必须首先正确地分配它。
还有一件事,HEDView是UIViewController,所以你应该遵循正确的命名约定
在AppDelegate中实现- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
。并在AppDelegate.h
@property (nonatomic, retain) UINavigationController *navControl;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil] autorelease];
navControl = [[UINavigationController alloc] initWithRootViewController:self.viewController];
[self.window addSubview:[navControl view]];
[self.window makeKeyAndVisible];
return YES;
}
我想这会对你有帮助。