欢迎访问移动开发之家(rcyd.net),关注移动开发教程。移动开发之家  移动开发问答|  每日更新
页面位置 : > > > 内容正文

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

来源: 开发者 投稿于  被查看 11515 次 评论:221

【代码笔记】iOS-在导航栏中显示等待对话框,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
复制代码

用户评论