zoukankan      html  css  js  c++  java
  • 【代码笔记】iOS-在导航栏中显示等待对话框

    一,效果图。

    二,代码。

    ViewController.m

    复制代码
    #import "ViewController.h"
    
    @interface ViewController ()
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
        
        //在导航栏中显示等待对话框
        [self showActivityIndicatorViewInNavigationItem];
        
    }
    //点击任何处,停止等待指示器
    -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
        
        //停止等待指示器,恢复导航栏
        self.navigationItem.titleView = nil;
        self.navigationItem.prompt = nil;
    }
    #pragma -mark -functions
    //在导航栏中显示等待对话框
    -(void) showActivityIndicatorViewInNavigationItem
    {
        UIActivityIndicatorView *aiview = [[UIActivityIndicatorView alloc]
                                           initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
        self.navigationItem.titleView = aiview;
        [aiview startAnimating];
        self.navigationItem.prompt = @"数据加载中...";
    }
    
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    @end
    复制代码
  • 相关阅读:
    匿名函数
    内置函数
    基础函数--3
    基础函数(2)
    基础函数(1)
    文件的相关操作
    知识点补充,set集合,深浅copy
    is 和 ==的区别
    Django-form组件中过滤当前用户信息
    Django的常用模块引入整理
  • 原文地址:https://www.cnblogs.com/yang-guang-girl/p/7416558.html
Copyright © 2011-2022 走看看