无法推送VIEW

时间:2011-08-25 07:34:53

标签: objective-c xcode uinavigationcontroller uitouch

我有一个DashBoard视图,上面有标签和imageViews。 在我的应用程序中,当我触摸任何ImageView时,我想推送一个静态页面中的视图。

我使用了UITouch的概念,它有方法“ - (void)touchesBegan:(NSSet *)触及withEvent:(UIEvent *)event”如下:

 - (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
NSLog(@"touches began");

if ( [touch view] == _icon) {
StaticPage *staticPage = [[StaticPage alloc] initWithNibName:@"StaticPage" bundle:nil];
[self.navigationController pushViewController:staticPage animated:YES];
[staticPage release];
}

}

其中从UIViewController继承的StaticPage。 _icon是一个UIImageView。

在AppDelegate中,此方法“ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions”如下:

  self.window.rootViewController = self.viewController;
[_window addSubview:navController.view];
[self.window makeKeyAndVisible];
return YES;

其中navController在StaticPage的.h文件中声明为UINavigationController * navController;并在StaticPage的.m文件中合成。

我想知道为什么我的静态页面视图没有被推送? 任何帮助......提前谢谢

1 个答案:

答案 0 :(得分:0)

我想出了导航但没有使用方法pushViewController:animated。 使用presentModalViewController:动画我们可以导航到所需的页面。