【代碼筆記】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