Như tôi đã đề cập trong tiêu đề, tôi muốn thêm Navigation Controller
vào đơn đăng ký của tôi đã có Tab Controller
. Vì vậy, cố gắng làm nhân viên như thế này trên page này. Dù sao, có điều gì đó không ổn. UINavigationController
đang tìm kiếm một trang trống, ngay cả khi có chế độ xem và một số thư viện.Kết hợp Bộ điều khiển Điều hướng với Bộ điều khiển Thanh tab
Hãy để tôi bắt đầu từ stracht:
Trong AppDelegate
của tôi, tôi đang thiết lập bộ điều khiển thanh tab như thế này:
@interface MYAppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UITabBarController *tabBarController;
@end
Và đây là tập tin .m:
@implementation MYAppDelegate
@synthesize window = _window;
@synthesize tabBarController = _tabBarController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
application.applicationSupportsShakeToEdit = YES;
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UINavigationController *viewController1 = [[[MYMainViewController alloc] init] initWithNibName: @"MYMainViewController" bundle:nil];
UIViewController *viewController2 = [[[MYPageViewController alloc] init] initWithNibName:@"MYPageViewController" bundle:nil];
UIViewController *viewController3 = [[[MYSearchViewController alloc] init] initWithNibName:@"MYSearchViewController" bundle:nil];
UIViewController *viewController4 = [[[MYPersonViewController alloc] init] initWithNibName:@"MYPersonViewController" bundle:nil];
// Initialize tabBarController and add ViewControllers
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects: viewController1, viewController2,
viewController3, viewController4, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
Sau đó, đây là MYMainViewController
triển khai là UINavigationController
:
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"%@", [self navigationController]); // Logging null
}
Tệp .xib của tôi có UINavigationController
và có chế độ xem trong đó. Mặc dù vậy, khi tôi làm việc ứng dụng, có trang trống và thanh điều hướng không có tiêu đề. Tôi đang làm gì sai?
Nếu tôi có thể xem nội dung của chế độ xem, tôi muốn điều hướng giữa hai bộ điều khiển chế độ xem bằng cách sử dụng nút quay lại.
Mọi trợ giúp hoặc cách tiếp cận sẽ rất tuyệt vời đối với tôi.
Cảm ơn, nhưng vẫn không có gì thay đổi. –
Được chấp nhận sau 20 ngày sau đó, sai lầm là của tôi. Một loại lỗi. Dù sao thì cũng cám ơn bạn. –