2010-01-16 70 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]; 
相關問題