0

我正在使用的代码

  NSLog(@"before Navigate to second activity");
    Signature *temp = [[Signature alloc]initWithNibName:@"Signature" bundle:nil];

    [self.navigationController pushViewController:temp animated:YES];

     NSLog(@"after Navigate to second activity");

在控制台上,两个日志语句都被打印出来,但我的应用程序没有将我导航到下一个视图。请纠正我。

4

4 回答 4

0

我认为您的应用程序没有使用 navigationController 所以在 AppDelegate.m 文件中分配 rootViewController 像这样..

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    RootViewController *viewController1 = [[[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil] autorelease];
    UINavigationController   *navviewController=[[UINavigationController alloc]initWithRootViewController:viewController1];
    self.window.rootViewController = navviewController;
    [self.window makeKeyAndVisible];
    return YES;
}

之后检查它的工作..

于 2012-11-19T11:38:20.360 回答
0

无论如何,日志消息都会显示,所以这并不奇怪。为该导航控制器的委托添加一个回调(当然,您必须首先设置一个委托)

navigationController:didShowViewController:animated:

在那里您可以确保 viewController 已通过(确保 Signature 是 ViewController 实例)。

于 2012-11-19T11:42:54.167 回答
0

如果您没有UINavigationController在您的应用程序上使用您不能调用的pushViewController,请presentViewController:animated:completion:改用:

[self presentViewController:temp animated:YES completion:nil];

有关更多信息,请查看文档

于 2012-11-19T12:13:07.300 回答
0

CreditsViewController *viewController = [[CreditsViewController alloc] init];

[[self navigationController] pushViewController:viewController 动画:YES];

[viewController 发布];

你可以试试上面的代码

于 2012-11-20T08:56:12.217 回答