iphone - UIActivityIndi​​catorView不会停止动画

时间:2009-08-14 08:55:17

标签: iphone activity-indicator

我有一个UIActivityIndi​​catorView,其中显示一条消息,指示用户在用户切换视图时指示下一个视图正在加载,或者在点击按钮时指向另一个视图。我添加了UIActivityIndi​​catorView,以便在启用用户交互之前,可以在api的当前视图中显示im获取的数据。 当前视图在后台加载时,UIActivityIndi​​catorView会使用等待消息正确设置动画。但是,即使在视图加载完成后,UIActivityIndi​​catorView也不会停止动画并永远继续! 我已经尝试了[停止动画]以及removefromSuperview但似乎都没有工作。我需要紧急解决这个问题。

下面是代码: - (无效)showWorkInProgress {        NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

   progressAlert = [[UIAlertView alloc] initWithTitle:@"Loading Data"
                                                           message:@"Please wait..."
                                                            delegate: self
                                               cancelButtonTitle: nil
                                                otherButtonTitles: nil];


   activityView = [[UIActivityIndicatorView alloc]

initWithActivityIndi​​catorStyle:UIActivityIndi​​catorViewStyleWhite];        activityView.frame = CGRectMake(139.0f-18.0f,80.0f,37.0f,37.0f);        [progressAlert addSubview:activityView];

   [activityView startAnimating];

   [progressAlert show];

   [pool drain];

} - (void)viewDidLoad {

   self.title = @"WordLife";
   UIImage *image = [UIImage imageNamed: @"cena.png"];
   UIImageView *imageview = [[UIImageView alloc] initWithImage: image];
   self.navigationItem.titleView = imageview;

   [imageview release];
   self.navigationItem.leftBarButtonItem.title = @"Back";


   [activityView removeFromSuperview];
   activityView = nil;
   [super viewDidLoad];

}

1 个答案:

答案 0 :(得分:1)

你可以发布你的代码吗?也许你用另一个替换第一个UIActivityIndi​​catorView或者在开始设置动画之前调用sopAnimating选择器?

也许更好的解决方案:
在调用stopAnimating-selector之后(或之前)放置一个NSLog(@“函数调用?”),这样你就可以看到(在日志中)是否调用了调用'stopAnimating'选择器的选择器。