【代码笔记】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
用户评论