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];
    }
  • 相关阅读:
    传智博客.NET培训第13季 Ajax教程(共十三季) 学习资源
    一些sql语句的常用总结(重要)
    处理oracle的死锁
    Adroid 总结--android ListView美化,个性化更改的属性
    如何远程备份sql server数据库
    VSS (Visual Source Safe 2005) 用法详解
    php插入代码数据库
    PHP之PHP文件引用详解
    需要引入库:vue-resource
    axios调用详解
  • 原文地址:https://www.cnblogs.com/code-style/p/4002417.html
Copyright © 2011-2022 走看看