0

我有一个要求,当用户单击登录屏幕上的提交按钮时,我需要为 a 设置动画UIActivityIndicator,但是 - 使用下面的代码 - 它不是动画:

-(IBAction)loginButtonAction:(id)sender {
    [currenttextfield resignFirstResponder];
    [self.spinner startAnimating];
    BOOL valid=[self emailvalidate];

    if(valid) {
        if (!self.passwordstring.length ==0  && ![self.passwordstring isEqualToString:@" "] && ![self.passwordstring isEqualToString:nil] && !self.emailstring.length ==0  && ![self.emailstring isEqualToString:@" "] && ![self.emailstring isEqualToString:nil] ) {
            [self performSelectorOnMainThread:@selector(sendDetails) withObject:nil waitUntilDone:YES];
        }
    }
}  

此方法首先调用EmailValidate返回一个BOOL值。如果有效,则调用发送详细信息方法,在该方法中我调用存储库来检查值。完成后,我停止活动指示器。有谁知道如何解决上述问题?

4

1 回答 1

1

如果您为活动指示器使用了界面构建器,则定义其 IBOutlet 及其属性。

-(IBAction)loginButtonAction:(id)sender{

    [currenttextfield resignFirstResponder];
    [activityIndicator startAnimating];

    BOOL valid=[self emailvalidate];
    if(valid) {
        if (!self.passwordstring.length ==0  && ![self.passwordstring isEqualToString:@" "] && ![self.passwordstring isEqualToString:nil] && !self.emailstring.length ==0  && ![self.emailstring isEqualToString:@" "] && ![self.emailstring isEqualToString:nil] ) {
            [self performSelectorOnMainThread:@selector(sendDetails) withObject:nil waitUntilDone:YES];
        }
    } }
于 2013-02-15T12:34:02.257 回答