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

Sam*_*nen 3 cocoa-touch objective-c uinavigationbar uiactivityindicatorview

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

Mat*_*att 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];  
Run Code Online (Sandbox Code Playgroud)

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