我正在使用的代码
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");
在控制台上,两个日志语句都被打印出来,但是我的应用程序没有导航到下一个View.Please更正我。
答案 0 :(得分: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;
}
之后检查它的工作..
答案 1 :(得分:0)
无论如何,日志消息都会显示出来,所以毫不奇怪。为该导航控制器的委托添加回调(当然必须为
设置委托)navigationController:didShowViewController:animated:
在那里你可以确保viewController传递(确保Signature是一个ViewController实例)。
答案 2 :(得分:0)
如果您在应用中未使用UINavigationController
,则无法拨打pushViewController
,请改为使用presentViewController:animated:completion:
:
[self presentViewController:temp animated:YES completion:nil];
有关详细信息,请查看documentation
答案 3 :(得分:0)
CreditsViewController * viewController = [[CreditsViewController alloc] init];
[[self navigationController] pushViewController:viewController animated:YES];
[viewController release];
您可以尝试上面的代码