【代码笔记】iOS-在导航栏中显示等待对话框

来源:互联网 发布:nginx server 配置 编辑:程序博客网 时间:2024/06/05 11:56

一,效果图。

二,代码。

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
复制代码
原创粉丝点击