1. Bước: Tạo một UIViewController mới:
- Xcode -> New File ... -> Cocoa Touch Class -> UIViewController
- Tên: MyViewControllerLàm thế nào để thêm một bộ điều khiển điều hướng với bộ dựng giao diện?
2. Bước: Kéo và thả một "Navigation Controller" (UINavigationController) từ Thư viện để MyViewController.xib
3.Bước: Tôi chắc chắn, tôi phải làm một cái gì đó để kết nối các điều khiển chính xác, phải không?
4.Step: Cố gắng khởi động mới View Controller như một hộp thoại modal:
MyViewController *myViewController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
NSLog(@"navContr: %@", myViewController.navigationController);
[self.navigationController presentModalViewController: myViewController animated:YES];
Kết quả: "navContr: nil"
5.Step: Bạn có thể xem chế độ xem mới (MyViewController), nhưng không có NavigationController và không có UINavigationBar.
Cảm ơn bạn rất nhiều vì đã giúp đỡ!
UPDATE 1:
6.Step: tôi đặt một UIViewController mới (ViewNavi2) như "Root View Controller":
7.Step: Tôi định nghĩa một IBOutlet UINavigationController *navigationController
trong lớp MyViewController và cấu hình xib: Trình điều khiển Điều hướng -> Kết nối -> Tham chiếu Cửa hàng
Nhưng điều khiển Navigation của tôi vẫn là con số không :-(
MyViewController *myViewController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
NSLog(@"navContr: %@", myViewController.navigationController);
// -> "navContr: nil"
[ở đây] (http://rdcworld-iphone.blogspot.in/2013/03/how-to-add-navigation-controller-in.html) là hướng dẫn đơn giản để thêm Bộ điều khiển điều hướng – swiftBoy