我正在尝试使用UITabBarController创建一个带有4个标签的项目,该标签为每个要插入不同对象和编写代码的标签滚动。
在一个空的应用程序中,我最初为4个选项卡创建了4个XIB,并且我使用以下代码成功创建了4个选项卡式视图。
//ExTabBarAppdelegate.m
#import "ExTabBarAppDelegate.h"
#import "PersonalViewController.h"
#import "EmpViewController.h"
#import "FinancialViewController.h"
#import "TermsViewController.h"
@implementation ExTabBarAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
UITabBarController *tabBarController=[[UITabBarController alloc]init];
PersonalViewController *perVC=[[PersonalViewController alloc]initWithNibName:@"PersonalViewController" bundle:nil];
EmpViewController *empVC=[[EmpViewController alloc]initWithNibName:@"EmpViewController" bundle:nil];
FinancialViewController *finVC=[[FinancialViewController alloc]initWithNibName:@"FinancialViewController" bundle:nil];
TermsViewController *terVC=[[TermsViewController alloc]initWithNibName:@"TermsViewController" bundle:nil];
[tabBarController setViewControllers:[NSArray arrayWithObjects:perVC, empVC, finVC, terVC, nil]];
self.window.rootViewController=tabBarController;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
但是我应该如何为每个标签启用滚动属性? 请帮忙 ! 在此先感谢...
答案 0 :(得分:0)
在您的XIB文件中,使用UIScrollView
代替UIView
作为viewController的视图。
这是一个关于UIScrollView的教程:
http://spin.atomicobject.com/2014/03/05/uiscrollview-autolayout-ios/