如何显示加载的表视图的 UIActivityIndi​​catorView

发布于 2024-12-13 12:37:03 字数 603 浏览 0 评论 0原文

一个相当短的问题,如何在视图加载后 0.5 秒内加载 UIActivityIndi​​catorView?

我环顾四周,但大多数教程都使用 webview,其中创建 if 语句,其中 (webview.loading) 用于定义动画的长度等。 所以我只是想知道如何在视图加载 0.5 秒时执行此操作。

目前,我有一种方法可以将先前选择的单元格居中,我希望指示器能够持续到完成为止。

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
[self performSelector:@selector(scrollToRowAtIndexPath) withObject:nil afterDelay:1.0];
}

- (void)scrollToRowAtIndexPath
{    
    [self.tableView reloadData];
    [self.tableView scrollToRowAtIndexPath:oldCheckedIndexPath atScrollPosition:UITableViewScrollPositionMiddle animated:NO];
}

A fairly short question, How can I load a UIActivityIndicatorView for say 0.5 seconds from when the view loads?

I have had a look around but most tutorials are using the webview where an if statment is created where (webview.loading) is used to define the length of the animation etc..
so i am just woundering how to do this when ever the view loads for .5 second.

Currently I have a method that centers the previously selected cell which I would like the indicator to last untill this is done.

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
[self performSelector:@selector(scrollToRowAtIndexPath) withObject:nil afterDelay:1.0];
}

- (void)scrollToRowAtIndexPath
{    
    [self.tableView reloadData];
    [self.tableView scrollToRowAtIndexPath:oldCheckedIndexPath atScrollPosition:UITableViewScrollPositionMiddle animated:NO];
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

国际总奸 2024-12-20 12:37:03

也许有些这样的帮助:

-(void)viewDidLoad
{
    [super viewDidLoad];

    //... all your previous charge.

    UIActivityIndicatorView *activity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];

    activity.hidesWhenStopped = YES;

    activity.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin |
        UIViewAutoresizingFlexibleHeight |
        UIViewAutoresizingFlexibleLeftMargin |
        UIViewAutoresizingFlexibleRightMargin |
        UIViewAutoresizingFlexibleTopMargin |
        UIViewAutoresizingFlexibleWidth;

    [yourTable addSubview:activity];

    [activity startAnimating];

    [activity performSelector:@selector(stopAnimating) withObject:nil afterDelay:0.5];

    [activity release];
}

Maybe some like that helps:

-(void)viewDidLoad
{
    [super viewDidLoad];

    //... all your previous charge.

    UIActivityIndicatorView *activity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];

    activity.hidesWhenStopped = YES;

    activity.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin |
        UIViewAutoresizingFlexibleHeight |
        UIViewAutoresizingFlexibleLeftMargin |
        UIViewAutoresizingFlexibleRightMargin |
        UIViewAutoresizingFlexibleTopMargin |
        UIViewAutoresizingFlexibleWidth;

    [yourTable addSubview:activity];

    [activity startAnimating];

    [activity performSelector:@selector(stopAnimating) withObject:nil afterDelay:0.5];

    [activity release];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文