一,效果圖。 二,代碼。 ViewController.m ...
一,效果圖。
二,代碼。
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