zoukankan      html  css  js  c++  java
  • 设置菜单和工具条

    代码:

    可任选一套方法进行显示和隐藏,如果决定有动画的那套,那么一开始初始化时就必须用set方法进行控制

    -(void) setBar
    {
        UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:nil];
        
        UIBarButtonItem *searchButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:nil];
        
        self.navigationItem.leftBarButtonItems = @[addButton, searchButton];
        
        UIBarButtonItem *organizeButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize target:self action:nil];
        
        [self setToolbarItems:@[organizeButton]];
    }
    
    -(void) showBar
    {
        // 无论哪套设置方法都可以这么判断是否隐藏
        if (self.navigationController.navigationBar.hidden)
        {
            NSLog(@"show it");
            
            // 两套隐藏方法,这套无动画,不可混用
            //self.navigationController.navigationBar.hidden = NO;
            //self.navigationController.toolbar.hidden = NO;
            
            // 有动画
            [self.navigationController setNavigationBarHidden:NO animated:YES];
            [self.navigationController setToolbarHidden:NO animated:YES];
            
        }
        else
        {
            NSLog(@"hide it");
            [self.navigationController setNavigationBarHidden:YES animated:YES];
            [self.navigationController setToolbarHidden:YES animated:YES];
        }
    }
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
        
        [self setBar];
        
    }
    
    -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
    {
        [self showBar];
    }
  • 相关阅读:
    函数的定义
    函数名的本质
    函数进阶
    三元运算
    数据类型 补充
    安装python问题
    neo4j nosql图数据库学习
    ubutun lunix 64安装neo4j 图形数据库
    git error: object file .git/objects/b9/e269f50db2a3415cc8ad5ba40b82b9b6a13d45 is empty
    django orm 时间处理
  • 原文地址:https://www.cnblogs.com/code-style/p/4002417.html
Copyright © 2011-2022 走看看