【问题标题】:Activity indicator not hiding when webpage is loaded加载网页时活动指示器不隐藏
【发布时间】:2013-08-28 13:40:29
【问题描述】:

网页完成加载后,活动指示器并未隐藏。 这是我的

.h 文件

@interface PropertyViewController : UIViewController{

    IBOutlet UIWebView *propertyNexusHome;
    IBOutlet UIActivityIndicatorView *wheel;
    NSTimer *timer;
}

.m 文件

- (void)viewDidLoad
{
    [super viewDidLoad];

    [property loadRequest:[NSURLRequest requestWithURL:
                         [NSURL URLWithString:@"http://www.google.com"]]];
    [property addSubview:wheel];
    timer = [NSTimer scheduledTimerWithTimeInterval:(1.0/2.0)
                                             target:self
                                           selector:@selector(loading)
                                           userInfo:nil
                                            repeats:YES];
    // Do any additional setup after loading the view, typically from a nib.
}
-(void)loading {
    if (!property.loading)
        [wheel stopAnimating];

    else
        [wheel startAnimating];

}

@end

我不知道为什么它没有消失,它是如何在页面加载后停止旋转的。

提前致谢。

【问题讨论】:

  • 你做的不对。加载开始后立即添加UIActivityIndicator,从UIWebView 委托中获取。并在加载完成或失败并出现错误时停止它。

标签: ios uiactivityindicatorview


【解决方案1】:

另一种选择是在创建活动指示器时设置[wheel setHidesWhenStopped:YES]

【讨论】:

    【解决方案2】:

    你必须添加:

    wheel.hidden = YES;
    

    当它停止动画时

    【讨论】:

      猜你喜欢
      • 2019-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多