我们可以在查看基础应用中使用 UITab栏控制器谢谢
答案 0 :(得分:1)
是的,你可以。
您可以查看Apple提供的“TheElements”示例。 你可以在这里找到它:
https://developer.apple.com/library/ios/#samplecode/TheElements/Introduction/Intro.html
查看应用代表。 这是一个非常紧张的前进例子。
对于你的请求我试图做一个简单的例子:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self setupPortraitUserInterface];
return YES;
}
- (UINavigationController *)AchievementsControllerWrappingViewController:(NSInteger*)tabIndex{
switch(tabIndex){
case 0:
FirstViewController *theViewController;
theViewController = [[FirstViewController alloc] init];
break;
case 1:
SecondViewController *theViewController;
theViewController = [[SecondViewController alloc] init];
break;
}
UINavigationController *theNavigationController;
theNavigationController = [[UINavigationController alloc] initWithRootViewController:theViewController];
[theViewController release];
return theNavigationController;
}
- (void)setupPortraitUserInterface {
UINavigationController *localNavigationController;
UIWindow *localWindow;
localWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window = localWindow;
[localWindow release];
tabBarController = [[UITabBarController alloc] init];
NSMutableArray *localViewControllersArray = [[NSMutableArray alloc] initWithCapacity:2];
for(int i=0;i<2;i++){
localNavigationController = [self AchievementsControllerWrappingViewController:i];
[localViewControllersArray addObject:localNavigationController];
[localNavigationController release];
}
tabBarController.viewControllers = localViewControllersArray;
[localViewControllersArray release];
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
}
我不是xCode的旁边,我用文本编辑做了,所以请在使用时检查。
SHANI
答案 1 :(得分:0)
是的,我们可以.. 为此你必须创建UITabBarViewController及其对象,然后用你的Application..like引用它:
在AppDelegate.h中
@interface youAppDelegate.h : UIApplicationDelegate {
UIWindow *window;
YourViewController *viewController;
// Declare Your TabBarController Here
UITabBarController *tabBar;
}
@property (nonautomic, retain) IBOutlet UIWindow *window;
@property (nonautomic, retain) IBOutlet TabBarViewController *tabBar;
@end
在您的实现文件的ApplicationDidFinish启动中添加以下代码
viewController = [[YourViewController alloc] init];
[viewController addSubView:tabBar];
[self.window addSubView:viewController];
在界面构建器中,您必须将TabBarController添加到MainWindow并将其与IBOutLet相关联。给出想要在tabBar中显示的视图。
享受..