Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 在Objective-c中以编程方式将底部栏设置为选项卡栏_Iphone_Objective C_Ios - Fatal编程技术网

Iphone 在Objective-c中以编程方式将底部栏设置为选项卡栏

Iphone 在Objective-c中以编程方式将底部栏设置为选项卡栏,iphone,objective-c,ios,Iphone,Objective C,Ios,在IB中,我可以将底部栏设置为屏幕截图下方视图的选项卡栏,但如何通过实现(.m)文件中的代码进行设置 谢谢 创建要使用的UIViewController的NSArray。然后实例化一个UITabBarController,并将viewControllers属性设置为此数组。然后将tabBarController的视图添加到窗口中。所有这些都应该在AppDelegate.m文件中完成。例如: - (BOOL)application:(UIApplication *)application did

在IB中,我可以将底部栏设置为屏幕截图下方视图的选项卡栏,但如何通过实现(.m)文件中的代码进行设置

谢谢


创建要使用的
UIViewController
NSArray
。然后实例化一个
UITabBarController
,并将
viewControllers
属性设置为此数组。然后将
tabBarController
视图添加到窗口中。所有这些都应该在AppDelegate.m文件中完成。例如:

- (BOOL)application:(UIApplication *)application 
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{   

    UIViewController *vc1 = [[UIViewController alloc] init];
    UIViewController *vc2 = [[UIViewController alloc] init];
    CustomViewController *vc3 = [[CustomViewController alloc] init];

    NSArray *viewControllers = [NSArray arrayWithObjects:vc1, vc2, vc3, nil];
    [vc1 release]; [vc2 release]; [vc3 release];

    UITabBarController *tabBarController = [[UITabBarController alloc] init];
    [tabBarController setViewControllers:viewControllers];

    [window addSubview:[tabBarController view]];
    [window makeKeyAndVisible];

    return YES;
}

创建要使用的
UIViewController
s的
NSArray
。然后实例化一个
UITabBarController
,并将
viewControllers
属性设置为此数组。然后将
tabBarController
视图添加到窗口中。所有这些都应该在AppDelegate.m文件中完成。例如:

- (BOOL)application:(UIApplication *)application 
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{   

    UIViewController *vc1 = [[UIViewController alloc] init];
    UIViewController *vc2 = [[UIViewController alloc] init];
    CustomViewController *vc3 = [[CustomViewController alloc] init];

    NSArray *viewControllers = [NSArray arrayWithObjects:vc1, vc2, vc3, nil];
    [vc1 release]; [vc2 release]; [vc3 release];

    UITabBarController *tabBarController = [[UITabBarController alloc] init];
    [tabBarController setViewControllers:viewControllers];

    [window addSubview:[tabBarController view]];
    [window makeKeyAndVisible];

    return YES;
}