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];
    }
  • 相关阅读:
    scrapy 断点续爬
    Tornado
    python 列表去重的几种方法
    安装Mysql-python报错EnvironmentError: mysql_config not found
    安装setuptools 报错缺少zlib
    微信小程序-if条件渲染
    微信小程序-遍历列表
    微信小程序-数据绑定
    超强过滤器
    如何在tomcat安装部署php项目
  • 原文地址:https://www.cnblogs.com/code-style/p/4002417.html
Copyright © 2011-2022 走看看