0
我怎樣才能從UIScrollView推動一個新的視圖到NavigationController的堆棧?從UIScrollView推導航控制器
我試圖
[self.navigationController pushViewController:myNewViewController animated:YES];
,但得到 「navigationController不是在結構或聯合」。
關於
我怎樣才能從UIScrollView推動一個新的視圖到NavigationController的堆棧?從UIScrollView推導航控制器
我試圖
[self.navigationController pushViewController:myNewViewController animated:YES];
,但得到 「navigationController不是在結構或聯合」。
關於
您的應用中沒有導航控制器。你需要創建一個。例如:
在您的appDelegate中創建一個UINavigationController實例變量,然後使用您現有的viewController作爲導航控制器的rootViewController。
例如在使用UITableViewController的純代碼中(您可以使用xibs以及您的模板應用程序可能會這樣做)。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Create root view and navigation controller
UITableViewController *rootViewController = [[[UITableViewController alloc] initWithStyle:UITableViewStyleGrouped] autorelease];
self.navigationController = [[[UINavigationController alloc] initWithRootViewController:rootViewController] autorelease];
// Not necessary if you're using xibs
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Add the nav controller's root view to the window
[window addSubview:navigationController.view];
[window makeKeyAndVisible];
return YES;
}
然後,您可以按照您嘗試的方式推/拉新視圖。
感謝瑞安,缺失的鏈接 - 再次 - 沒有考慮明顯的...設置一個IBOutlet來連接導航控制器。 – iFloh 2010-06-20 13:11:39
啊。這將做到這一點。 :) – 2010-06-20 14:25:46