UINavigationBar 中的活动指示器
我已经阅读了有关此特定主题的一些答案,但由于某种原因,我的代码似乎不起作用。它位于 UISearchBarDelegate 委托方法 -(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
中,
UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
UIBarButtonItem *activity = [[UIBarButtonItem alloc] initWithCustomView:activityIndicator];
[[self navigationItem] setRightBarButtonItem:activity];
[activity release];
[activityIndicator startAnimating];
非常感谢任何帮助或建议!
I've read a few answers about this particular topic, but for some reason, my code doesn't seem to work. It's within the UISearchBarDelegate delegate method -(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
UIBarButtonItem *activity = [[UIBarButtonItem alloc] initWithCustomView:activityIndicator];
[[self navigationItem] setRightBarButtonItem:activity];
[activity release];
[activityIndicator startAnimating];
Any help or suggestions are much appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我相信
UIActivityIndicatorView
的指定初始化程序是initWithActivityIndicatorStyle:
。尝试像这样创建activityIndicator
。I believe the designated initializer for
UIActivityIndicatorView
isinitWithActivityIndicatorStyle:
. Try creatingactivityIndicator
like this.试试这个
try this
试试这个:
也可以使用它来停止和删除 ActivityIndicator:
try this:
Also use this for stopping and removing activityIndicator: