day021 UINavigationcontroller

//
//  AppDelegate.m
//  NavigationController
//
//  Created by 蔡定龙 on 15-4-13.
//  Copyright (c) 2015年 李灵杰. All rights reserved.
//

#import "AppDelegate.h"
#import "ViewController.h"

@interface AppDelegate ()
            

@end

@implementation AppDelegate
            

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    //创建一个导航栏
    
    //为导航栏创建一个界面
    ViewController *vc = [[ViewController alloc]init];
    //将界面作为导航栏控制器的主界面
    UINavigationController *nvc = [[UINavigationController alloc]initWithRootViewController:vc];
    //将导航栏控制器设置为window的启动界面
    self.window.rootViewController = nvc;
    
    
    return YES;
}


@end


//
//  ViewController.m
//  NavigationController
//
//  Created by 蔡定龙 on 15-4-13.
//  Copyright (c) 2015年 李灵杰. All rights reserved.
//

#import "ViewController.h"
#import "SecondViewController.h"

@interface ViewController ()
            

@end

@implementation ViewController
            
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    UIImage *bgimage = [UIImage imageNamed:@"Main_BG"];
    self.view.backgroundColor = [UIColor colorWithPatternImage:bgimage];
    UIBarButtonItem *leftUIBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"Setting" style:UIBarButtonItemStylePlain target:nil action:nil];
    self.navigationItem.leftBarButtonItem = leftUIBarButtonItem;
    
    UIBarButtonItem *rightUIBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:nil action:nil];
    self.navigationItem.rightBarButtonItem = rightUIBarButtonItem;
    
    
    self.navigationController.toolbarHidden = NO;
    UIBarButtonItem *camera = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"Main_ToolBar_Icon_Camera"] style:UIBarButtonItemStylePlain target:nil action:nil];
    UIBarButtonItem *library = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"Main_ToolBar_Icon_Library"] style:UIBarButtonItemStylePlain target:nil action:nil];
    UIBarButtonItem *addFolder = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"Main_ToolBar_Icon_AddFolder"] style:UIBarButtonItemStylePlain target:nil action:nil];
    UIBarButtonItem *jianju = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
    NSArray *barButtonItemsArray = @[jianju,camera,jianju,library,jianju,addFolder,jianju];
    //3.将数组设置为toolBar的array
    self.toolbarItems = barButtonItemsArray;
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    button.frame = CGRectMake(100, 200, 120, 50);
    [button setTitle:@"计算" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(changetoNext) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    
    UITextField *firstUITextField = [[UITextField alloc]initWithFrame:CGRectMake(20, 150, 120, 40)];
    
    firstUITextField.backgroundColor = [UIColor lightGrayColor];
    [firstUITextField setBorderStyle:UITextBorderStyleRoundedRect];
    [firstUITextField setPlaceholder:@"请输入一个整数"];
    firstUITextField.font = [UIFont fontWithName:nil size:14];
    [firstUITextField setKeyboardType:UIKeyboardTypeNumberPad];
    [firstUITextField setTextAlignment:NSTextAlignmentCenter];
    [self.view addSubview:firstUITextField];
    
    
    UITextField *secondUITextField = [[UITextField alloc]initWithFrame:CGRectMake(170, 150, 130, 40)];
    secondUITextField.backgroundColor = [UIColor lightGrayColor];
    [secondUITextField setBorderStyle:UITextBorderStyleRoundedRect];
    [secondUITextField setPlaceholder:@"请输入一个整数"];
    secondUITextField.font = [UIFont fontWithName:nil size:14];
    [secondUITextField setKeyboardType:UIKeyboardTypeNumberPad];
    [secondUITextField setTextAlignment:NSTextAlignmentCenter];
    [self.view addSubview:secondUITextField];
    
    //输出框
    UILabel *resultLable = [[UILabel alloc]initWithFrame:CGRectMake(85, 270, 150, 40)];
    resultLable.backgroundColor = [UIColor lightGrayColor];
    
    [self.view addSubview:resultLable];
    

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (void)changetoNext{
    SecondViewController *svc = [[SecondViewController alloc]init];
    //[self.navigationController pushViewController:svc animated:YES];
    [self presentViewController:svc animated:YES completion:nil];
}
@end

//
//  SecondViewController.h
//  NavigationController
//
//  Created by 蔡定龙 on 15-4-14.
//  Copyright (c) 2015年 李灵杰. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface SecondViewController : UIViewController

@end

//
//  SecondViewController.m
//  NavigationController
//
//  Created by 蔡定龙 on 15-4-14.
//  Copyright (c) 2015年 李灵杰. All rights reserved.
//

#import "SecondViewController.h"


@interface SecondViewController ()

@end

@implementation SecondViewController

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    /*
     导航栏的标题
     1.文本 title
     2.视图 titleView
     */
    self.title =@"news";
    UIButton *titleButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    titleButton.frame = CGRectMake(0, 0, 100, 44);
    [titleButton setTitle:@"anniu" forState:UIControlStateNormal];
    self.navigationItem.titleView = titleButton;
    
    
    UIImage *bgimage = [UIImage imageNamed:@"Main_BG"];
    self.view.backgroundColor = [UIColor colorWithPatternImage:bgimage];
    UIBarButtonItem *leftUIBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"Setting" style:UIBarButtonItemStylePlain target:nil action:nil];
    self.navigationItem.leftBarButtonItem = leftUIBarButtonItem;
    
    UIBarButtonItem *rightUIBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:nil action:nil];
    self.navigationItem.rightBarButtonItem = rightUIBarButtonItem;
    
    
    self.navigationController.toolbarHidden = NO;
    UIBarButtonItem *cut = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"ToolBar_Icon_Cut"] style:UIBarButtonItemStylePlain target:nil action:nil];
    UIBarButtonItem *copy = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"ToolBar_Icon_Copy"] style:UIBarButtonItemStylePlain target:nil action:nil];
    UIBarButtonItem *delete = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"ToolBar_Icon_Delete"] style:UIBarButtonItemStylePlain target:nil action:nil];
    UIBarButtonItem *more = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"ToolBar_Icon_More"] style:UIBarButtonItemStylePlain target:nil action:nil];
    UIBarButtonItem *jianju = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
    NSArray *barButtonItemsArray = @[jianju,cut,jianju,copy,jianju,delete,jianju,more,jianju];
    //3.将数组设置为toolBar的array
    self.toolbarItems = barButtonItemsArray;

    
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    button.frame = CGRectMake(100, 200, 120, 50);
    
    [button setTitle:@"返回结果" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(comeBack) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    
    UIButton *jia = [UIButton buttonWithType:UIButtonTypeCustom];
    jia.frame = CGRectMake(40, 100, 30, 30);
    [jia setTitle:@"+" forState:UIControlStateNormal];
    jia.titleLabel.font = [UIFont systemFontOfSize:50];
    [self.view addSubview:jia];
    UIButton *jian = [[UIButton alloc]initWithFrame:CGRectMake(110, 100, 30, 30)];
    UIButton *cheng = [[UIButton alloc]initWithFrame:CGRectMake(180, 100, 30, 30)];
    UIButton *chu = [[UIButton alloc]initWithFrame:CGRectMake(250, 100, 30, 30)];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    
}

- (void)comeBack{
    //push pop
    //[self.navigationController popViewControllerAnimated:YES];
    
    //model dismiss
    //[self.navigationController dismissViewControllerAnimated:YES completion:nil];
    [self dismissViewControllerAnimated:YES completion:nil];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end


重点熟悉NavigationBar 和ToolBar的属性用法
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值