谢谢!我的指标现在正在工作。
我正在为其他菜鸟分享一个代码示例,以便将其放在上下文中。
- (void)viewDidLoad
// custom button images
UIImage *customImage = [UIImage imageNamed:@"menu24"];
UIImage *customImage2 = [UIImage imageNamed:@"search24"];
UIImage *customImage3 = [UIImage imageNamed:@"back24"];
// These are linked in my story board to Navigation Item
[self customiseBarBtnItem:[self menu_button]
customImage:customImage selector:@selector(menuPressed:)];
[self customiseBarBtnItem:[self search_button]
customImage:customImage2 selector:@selector(searchPressed:)];
[self customiseBarBtnItem:[self backButton]
customImage:customImage3 selector:@selector(backPressed:)];
//initialize the activity indicator - as @antf comment suggests for ios7
UIActivityIndicatorView *actInd=[[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
//store it as a property on the view controller
self.activityIndicator = actInd;
// this sets up activity indicator
UIBarButtonItem *progress_indicator = [[UIBarButtonItem alloc]
initWithCustomView:[self activityIndicator]];
// link custom buttons AND activity indicator in desired order to navigation bar
self.navigationItem.rightBarButtonItems =
[NSArray arrayWithObjects:
self.menu_button,
self.search_button,
progress_indicator,
nil];
// 为了完整性 - 这就是我以编程方式显示/隐藏我的后退按钮的方式
if ( bShowBack == YES )
self.navItemBar.leftBarButtonItem = self.backButton;
else
self.navItemBar.leftBarButtonItem = Nil;
// 我将我的活动指示器与 UIWebView 一起使用,因此按如下方式触发它
- (void)webViewDidStartLoad:(UIWebView *)webView
{
[[self activityIndicator] startAnimating];
}
- (void)didFailLoadWithError:(UIWebView *)webView
didFailLoadWithError:(NSError *)error
{
[[self activityIndicator] stopAnimating];
}
- (void)webViewDidFinishLoad:(UIWebView *) webView
{
[[self activityIndicator] stopAnimating];
}