活动指示器不在iPhone中动画

时间:2013-02-15 11:45:32

标签: iphone ios6 xcode4.5 uiactivityindicatorview

我要求当用户点击“登录”屏幕上的“提交”按钮时,我需要为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值。如果有效,则调用发送详细信息方法,我在其中调用存储库来检查值。完成后,我停止活动指示器。有谁知道如何解决上述问题?

1 个答案:

答案 0 :(得分: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];
        }
    } }