IOS_UITabBarController



简单制作一个UITabBar页面 显示TabBar页面无其他内容

#import <UIKit/UIKit.h>


@interface AppDelegate : UIResponder <UIApplicationDelegate>


@property (strong, nonatomic) UIWindow *window;



@end

#import "AppDelegate.h"

#import "OneViewController.h"

#import "TwoViewController.h"

#import "ThreeViewController.h"

#import "FourViewController.h"

#import "FiveViewController.h"

#import "SixViewController.h"

#import "SevenViewController.h"


@interface AppDelegate ()


@end


@implementation AppDelegate

- (void)dealloc

{

    [_window release];

    [super dealloc];

}

//tab->Navi->vc

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

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    // Override point for customization after application launch.

    self.window.backgroundColor = [UIColor yellowColor];

    [self.window makeKeyAndVisible];

    [_window release];

    

    //创建视图控制器

    OneViewController *firstVC = [[OneViewController alloc]init];

    

    firstVC.title = @"第一页";

    firstVC.tabBarItem = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemBookmarks tag:100];

    firstVC.tabBarItem.badgeValue = @"1";

    //1.TabBar->Navi->VC

    UINavigationController *firstNaviVC = [[UINavigationController alloc]initWithRootViewController:firstVC];

    

    

    TwoViewController *secVC= [[TwoViewController alloc]init];

    

    secVC.title = @"第二页";

    //不在这些文字就在后面此页的初始化方法里面写

    secVC.tabBarItem = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemFavorites tag:101];

    

    ThreeViewController *thirdVC = [[ThreeViewController alloc]init];

    

    thirdVC.title = @"第三页";

    thirdVC.tabBarItem = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemMore tag:102];

    

    FourViewController *forthVC = [[FourViewController alloc]init];

    

    forthVC.title = @"第四页";

//    UIImage *image = [UIImage imageNamed:@"/Users/dllo/Desktop/UI/UI_Lesson/UI_lessson8/UI_Lesson12_UITabBarController/UI_Lesson12_UITabBarController/iconfont-paxingdeyinger.png"];

//    forthVC.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"iconfont-moban" image:image tag:103];

    //自定义图标 如果图表大 就在工程里的图片名后面加@2x

    // 6Plus 用3x 表示3倍像素

    forthVC.tabBarItem.image = [UIImage imageNamed:@"iconfont-paxingdeyinger"];

    //渲染模式 让图片在显示的时候始终以原始状态显示

    UIImage *image = [UIImage imageNamed:@"iconfont-paxingdeyinger"];

    image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

    forthVC.tabBarItem.image = image;

    //调整文字大小

    [forthVC.tabBarItem setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:22]}forState:UIControlStateNormal];

    

    FiveViewController *fifthVC = [[FiveViewController alloc]init];

    

    fifthVC.title = @"第五页";

//    fifthVC.tabBarItem.image = [UIImage imageNamed:@"iconfont-moban@3x"];

    

    SixViewController *sixthVC = [[SixViewController alloc]init];

    

    sixthVC.title = @"第六页";

    

    SevenViewController *sevenVC = [[SevenViewController alloc]init];

    

    sevenVC.title = @"第七页";


    

    //UITabBarController 的使用

    

    UITabBarController *tabBarVC = [[UITabBarController alloc]init];

    

    //设置tabBarVC要显示的视图控制器

//    

//    tabBarVC.viewControllers = @[firstNaviVC,secVC,thirdVC,forthVC,fifthVC,sixthVC,sevenVC];

    tabBarVC.viewControllers = [NSArray arrayWithObjects:firstNaviVC,secVC,thirdVC,forthVC,fifthVC,sixthVC,sevenVC, nil];

    

    self.window.rootViewController = tabBarVC;

    [tabBarVC release];

    

    [firstVC release];

    [secVC release];

    [thirdVC release];

    [forthVC release];

    [fifthVC release];

    [sixthVC release];

    [sevenVC release];

    

    return YES;

}


//是全屏显示 如果要做小屏的需要做tableview

#import "MainTableViewController.h"


@interface MainTableViewController ()


@end


@implementation MainTableViewController


- (void)viewDidLoad {

    [super viewDidLoad];

    //已经设置好tableview,用的时候直接写就好了.

    

    

    // Uncomment the following line to preserve selection between presentations.

    //视图翻页时取消选中状态

    // self.clearsSelectionOnViewWillAppear = NO;

    

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.

    //视图右上角加编辑状态

    // self.navigationItem.rightBarButtonItem = self.editButtonItem;

}


- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}


#pragma mark - Table view data source


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

#warning Potentially incomplete method implementation.

    // Return the number of sections.

    //分区 自己填

    return 0;

}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

#warning Incomplete method implementation.

    // Return the number of rows in the section.

    //每个区的行数

    return 0;

}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuseIdentifier" forIndexPath:indexPath];

    if (!cell) {

        cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"reuseIdentifier"]autorelease];

    }

    // Configure the cell...

    cell.textLabel.text = @"qianqian";

    return cell;

}




// Override to support conditional editing of the table view.

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {

    // Return NO if you do not want the specified item to be editable.

    //能不能被编辑

    return YES;

}




// Override to support editing the table view.

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

    if (editingStyle == UITableViewCellEditingStyleDelete) {

        // Delete the row from the data source

        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];

    } else if (editingStyle == UITableViewCellEditingStyleInsert) {

        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view

    }   

}




// Override to support rearranging the table view.

//移动

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {

}




// Override to support conditional rearranging of the table view.

//可不可以移动

- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {

    // Return NO if you do not want the item to be re-orderable.

    return YES;

}

#import <UIKit/UIKit.h>


@interface OneViewController : UIViewController


@end

#import "OneViewController.h"


@interface OneViewController ()


@end


@implementation OneViewController


- (void)viewDidLoad {

    [super viewDidLoad];

    // Do any additional setup after loading the view.

}


- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

       self.view.backgroundColor = [UIColor redColor];

}


#import <UIKit/UIKit.h>


@interface TwoViewController : UIViewController


@end

#import "TwoViewController.h"


@interface TwoViewController ()


@end


@implementation TwoViewController


- (void)viewDidLoad {

    [super viewDidLoad];

    // Do any additional setup after loading the view.

       self.view.backgroundColor = [UIColor whiteColor];

}


#import <UIKit/UIKit.h>


@interface ThreeViewController : UIViewController


@end

#import "ThreeViewController.h"


@interface ThreeViewController ()


@end


@implementation ThreeViewController


- (void)viewDidLoad {

    [super viewDidLoad];

    // Do any additional setup after loading the view.

       self.view.backgroundColor = [UIColor yellowColor];

}



#import <UIKit/UIKit.h>


@interface FourViewController : UIViewController


@end

#import "FourViewController.h"


@interface FourViewController ()


@end


@implementation FourViewController


- (void)viewDidLoad {

    [super viewDidLoad];

    // Do any additional setup after loading the view.

       self.view.backgroundColor = [UIColor redColor];

}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值