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