我正在構建一個基於TabBar的應用程序。其中一個選項卡將顯示一個TableView,我想在頂部有一個NavigationBar。TabBar應用程序與NavigationBar
但是我需要將本應用程序中的所有內容本地化爲多種語言,因此需要在代碼中完成。
我有在AppDelegate中設置的標籤欄;
@implementation AppDelegate
@synthesize window = _window;
@synthesize tabBarController = _tabBarController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
UIViewController *viewController1 = [[HomeViewController alloc] initWithNibName:@"HomeView" bundle:nil];
UIViewController *viewController2 = [[RecycleViewController alloc] initWithNibName:@"RecycleView" bundle:nil];
UIViewController *viewController3 = [[SettingsViewController alloc] initWithNibName:@"SettingsView" bundle:nil];
UIViewController *viewController4 = [[SettingsViewController alloc] initWithNibName:@"SettingsView" bundle:nil];
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;
}
每個窗口都有該選項卡上信息的代碼。
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = NSLocalizedString(@"Home", @"Home");
self.tabBarItem.image = [UIImage imageNamed:@"home"];
}
return self;
}
到目前爲止好,但RecyclingView(TableView)需要一個導航欄,我可以使用NSLocalizedString設置標題。
我會很感激一些幫助。