如何向导航栏添加活动指示器?

时间:2010-12-02 19:12:31

标签: objective-c cocoa-touch uinavigationbar uiactivityindicatorview

嘿,当我的用户更改选择器轮中的选择时,我想在导航栏的右上角显示一个活动指示器。我不知道如何在那里添加活动指示器我只能在那里添加普通的导航栏按钮。有帮助吗?提前谢谢!

1 个答案:

答案 0 :(得分:7)

UIActivityIndicatorView *activityIndicator =  
[[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];  
UIBarButtonItem *barButton = [[UIBarButtonItem alloc] 
                                         initWithCustomView:activityIndicator];  
[[self navigationItem] setRightBarButtonItem:barButton];  

[barButton release];  
[activityIndicator startAnimating];  

这应该有效。 来自:http://iosdevelopertips.com/user-interface/adding-an-activity-indicator-spinner-to-navigation-bar.html