当我点击按钮(刷新)时,我想在NavigationBar中显示一个循环进度指示器代替标题,当刷新成功时,指示消失,标题将再次显示。
有什么建议吗?谢谢。
答案 0 :(得分:0)
您可以编写将UIActivityIndicatorView添加到UInavigatiobar中的代码,如: -
UIView *activityView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
activityView.backgroundColor = [UIColor clearColor];
UIActivityIndicatorView *act =[[UIActivityIndicatorView alloc] init]; //create this globule so u can stop it while your progress finished
act.frame=CGRectMake(0, 0, 30, 30);
[activityView addSubview:act];
self.navigationItem.titleView = activityView;
注意: - [act startAnimating];
和[act stopAnimating];
符合您的需要
或者您可以将其添加到UInavigation BarbuttonItem
中 UIView *activityView = [[UIView alloc] initWithFrame:CGRectMake(0,0,30,30)];
UIActivityIndicatorView *act =[[UIActivityIndicatorView alloc] init];
act.frame=CGRectMake(0, 0, 30, 30);
UIBarButtonItem *actItem = [[[UIBarButtonItem alloc] initWithCustomView:activityView] autorelease];
[activityView addSubview:act];
self.navigationItem.rightBarButtonItem = actItem;
注意: - [UIActivityIndicatorView startAnimating];
和[UIActivityIndicatorView stopAnimating];
符合您的需要