2010-01-16 26 views
1

我有一个奇怪的问题。我有两个UItextfields在我的视图和一个按钮。当我点击button.I已经改变了动画块的视图框架,但它的辞职后来这里是我的代码,如果有人告诉我这个我“会感谢现在Textfield resignFirstResponder很晚?

-(IBAction)SignINClicked 
{ 
    [Email resignFirstResponder]; //TextField 
[Password resignFirstResponder];//TextField 
[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDuration:0.10]; 
[[self view] setFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)]; 
[UIView commitAnimations]; 
sleep(0.10); 
if([Email.text isEqualToString:@""] || [Password.text isEqualToString:@""]) 
{ 
    if([Email.text isEqualToString:@""] && [Password.text isEqualToString:@""]) 
    { 
     UIAlertView *Error = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Please fill email and password" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
     [Error show]; 
     [Error release]; 
    }  
    else if([Email.text isEqualToString:@""]) 
    { 
     UIAlertView *Error = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Please fill email" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
     [Error show]; 
     [Error release]; 
    } 
    else if([Password.text isEqualToString:@""]) 
    { 
      UIAlertView *Error = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Please fill password" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
      [Error show]; 
      [Error release]; 
    } 
} 
else 
{ 
    [AppDelegate startLoading];  
    BOOL isCorrectUser=[self logIn:Email.text Password:Password.text]; 
    if (isCorrectUser==TRUE) 
    { 
     if(checkboxSelected==1) 
      [self rememberMe:YES]; 
     else 
      [self rememberMe:NO]; 
     [self performSelector:@selector(ShowDashboard) withObject:nil afterDelay:5]; 
    } 
    else 
    { 
     [AppDelegate endLoading]; 
     UIAlertView *Error = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Either user name/password is incorrect" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
     [Error show]; 
     [Error release]; 
    } 
} 

}

-(void)startLoading 
{ 
[UIApplication sharedApplication].networkActivityIndicatorVisible=YES; 
if(MyWaitViewObj==nil) 
{ 
    MyWaitViewObj = [[MyWaitViewController alloc] initWithNibName:@"MyWaitView" bundle:nil]; 
} 
[NSThread detachNewThreadSelector:@selector(showMyWaitView) toTarget:self withObject:nil]; 
[NSThread sleepForTimeInterval:0.1]; 
} 

-(void)endLoading 
{ 
[MyWaitViewObj.view removeFromSuperview]; 
[UIApplication sharedApplication].networkActivityIndicatorVisible=NO; 
} 

当我登入按钮,点击[的appdelegate startloading]方法执行,然后再键盘hides.While其实首先应该隐藏键盘,然后开始loading

回答

2

尝试取出睡眠声明。如果您在延迟后需要某些事情发生,请将其置于其自己的方法中,并将其命名为:

[self performSelector:@selector(someMethod:) withObject:nil afterDelay:someTimeDelay]; 
相关问题