2012-05-26 93 views
0

活動指示器在我的代碼中不動畫。我有folowing代碼活動指示器不動畫IOS

我該如何解決它?是否因爲意思線程不更新指示器狀態?如果是這樣,我該如何解決它?

@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]; 


} 

回答

3

分配標籤和活動的指標我有類似的問題

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


} 

上面應該工作