代码之家  ›  专栏  ›  技术社区  ›  Parth Bhatt

如何在后台任务进行时显示一些处理?

  •  1
  • Parth Bhatt  · 技术社区  · 14 年前

    我正在制作一个iPhone应用程序,我需要用户输入他们的电子邮件ID和密码,然后他们可以在我的网站上访问他们的帐户。

    一旦他们输入身份验证详细信息,他们必须等待几秒钟,下一页才会出现。

    我需要向用户显示“正在处理”或“请稍候”类型的符号。

    我应该如何实现它?

    请帮帮我。

    4 回复  |  直到 13 年前
        1
  •  2
  •   ParthBhattParthBhatt    14 年前

    你要找的是一个活动指示器。

    下面是活动指示器的教程。

    http://www.edumobile.org/iphone/iphone-programming-tutorials/use-activityindicator-in-iphone/

    希望对你有帮助

        2
  •  1
  •   Rog    14 年前

    我通常创建一个根据需要实例化的UIView。下面是一些代码,供您在自己的应用程序中尝试:

    - (id)initWithLabel:(NSString*)labelName {
        self = [super init];
        if (self) {
            UIImageView *loadingBackgroundView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 150, 120, 40)];
            [loadingBackgroundView setBackgroundColor:[UIColor blackColor]];
            [loadingBackgroundView setAlpha:0.9];
            [loadingBackgroundView.layer setCornerRadius:8.0];
            [loadingBackgroundView.layer setBorderColor:[[UIColor clearColor] CGColor]];
            [self addSubview:loadingBackgroundView];
            [loadingBackgroundView release];
    
            UILabel *loadingLabel = [[UILabel alloc] initWithFrame:CGRectMake (125, 160, 100, 20)];
            [loadingLabel setBackgroundColor:[UIColor clearColor]];
            [loadingLabel setTextAlignment:UITextAlignmentCenter];
            [loadingLabel setTextColor:[UIColor whiteColor]];
            [loadingLabel setText:labelName];
            [self addSubview:loadingLabel];
            [loadingLabel release];
    
            UIActivityIndicatorView *loadingActivityIndicatorView = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(110,160,20,20)];
            [loadingActivityIndicatorView setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhiteLarge];
            [loadingActivityIndicatorView startAnimating];
            [self addSubview:loadingActivityIndicatorView];     
            [loadingActivityIndicatorView release];
        }
        return self;
    }
    

    这将为您提供类似于以下内容的内容: alt text

        3
  •  0
  •   Matthew Frederick    14 年前

    正如ParthBhatt所说,这是一个你想要的活动指标。

    我非常喜欢David Sinclair的DSActivityView类:非常容易实现,易于显示和更改消息,如果需要的话,它可以通过覆盖它来禁用UI,包括一个选项卡栏和导航栏。

    http://www.dejal.com/developer/dsactivityview

        4
  •  0
  •   Neal L    14 年前

    这是很多人处理过的事情,所以如果你想利用别人的工作,避免重新发明轮子,你可以使用类似于 Tapku Library . 它是开源的,在GitHub上。

    具体来说,看看 TKProgressAlertView TKLoadingView 上课。