活动指示器不动画IOS

时间:2012-05-26 21:31:53

标签: ios uiactivityindicatorview

活动指示器不会在我的代码中设置动画。我有以下代码

我该如何解决?是因为平均线程不更新指标状态?如果是这样我该如何解决?

@interface ConnectionEstablishedViewController : UIViewController{
 IBOutlet UIActivityIndicatorView * activityView;
    IBOutlet UILabel *loadingLabel;
}
@property(nonatomic,retain)  UIActivityIndicatorView * activityView;

我在my.xib文件中分配了标签和活动指示器

的.m

- (void) threadStartAnimating {
    [activityView startAnimating];
    loadingLabel.hidden=YES;
}
- (void) threadStopAnimating {
    [activityView startAnimating];
    loadingLabel.hidden=NO;
}


-(void)viewDidAppear:(BOOL)animated{


    [self threadStartAnimating];
    [NSThread sleepForTimeInterval:3.0];
    [self hunttable];//call hunttable in order to fetch hunt table data

    [NSThread sleepForTimeInterval:3.0];//sleep to prevent thread from overlap

    [self huntingarea];
    [NSThread sleepForTimeInterval:3.0];

    [self stands]; 
    [NSThread sleepForTimeInterval:3.0];

    [self weapons];
    [NSThread sleepForTimeInterval:3.0];

    [self backpack];
    [NSThread sleepForTimeInterval:3.0];

    [self descriptionget];
    [NSThread sleepForTimeInterval:3.0];

    [self threadStopAnimating];


}

1 个答案:

答案 0 :(得分:3)

我有类似的问题

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self threadStartAnimating];
}
-(void)viewDidAppear:(BOOL)animated{
    .
    ...//functions
    [self threadStopAnimating];


}

以上应该有效