【问题标题】:iphone - UIActivityIndicatorView doesnt stop animatingiphone - UIActivityIndi​​catorView 不会停止动画
【发布时间】:2009-08-14 08:55:17
【问题描述】:

我有一个 UIActivityIndi​​catorView,当用户切换视图或点击按钮被定向到另一个视图时,它会显示一条消息,向用户指示下一个视图正在加载。我添加了 UIActivityIndi​​catorView 以便我从 api 获取要显示在当前视图中的数据可以在启用用户交互之前完成。 当当前视图在后台加载时,UIActivityIndi​​catorView 会正确地使用等待消息进行动画处理。然而,即使在视图加载完成后, UIActivityIndi​​catorView 也不会停止动画并永远继续! 我已经尝试过 [stop Animating] 和 removefromSuperview,但似乎都不起作用。我需要紧急解决这个问题。

代码如下: -(void)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];

}

【问题讨论】:

    标签: iphone activity-indicator


    【解决方案1】:

    你能发布你的代码吗?也许您将第一个 UIActivityIndi​​catorView 替换为另一个,或者在它开始动画之前调用 sopAnimating 选择器?

    也许是一个更好的解决方案:
    在调用 stopAnimating-selector 之后(或之前)放置一个 NSLog(@"Is the function called?") 以便您可以(在日志中)查看调用 'stopAnimating'-selector 的选择器是否被调用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多