在navigationBar中的activityindicator动画

时间:2012-03-21 11:17:11

标签: iphone ios

在我的应用程序中使用以下方法下载图像和歌曲

-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
-(void) handleResponse :(NSDictionary *) responsedata

我在viewDidLoad中写了以下内容。

self.navigationItem.hidesBackButton = YES;
self.navigationController.navigationBar.frame = CGRectMake(0, 0, 480, 44);
UIBarButtonItem *actItem = [[UIBarButtonItem alloc] initWithCustomView:self.navView] ;
self.navigationItem.rightBarButtonItem = actItem;
self.activityIndicator.hidden  = YES;

在我的课堂上,当我按下按钮(意味着从网址下载图片和歌曲)时,会有一个按钮,activityindicator应该动画。

在按钮动作中,我写了

 self.activityIndicator.hidden  = NO;
 [self.activityIndicator staryAnimating];

但是当我点击按钮时,Activityindicator不是diplaying。

3 个答案:

答案 0 :(得分:2)

答案 1 :(得分:1)

试试这个

UIBarButtonItem *indicatorBtn=[[UIBarButtonItem alloc] initWithCustomView:self.activityIndicator];
[self.navigationItem setRightBarButtonItem:indicatorBtn animated:YES];

然后调用此

self.activityIndicator.hidden = NO;
[self.activityIndicator startAnimating];

答案 2 :(得分:1)

  • 替换以下行我认为它的拼写错误 -

    [self.activityIndi​​cator staryAnimating];

    [self.activityIndi​​cator startAnimating];