2013-03-18 38 views
3

調用UIKeyboard時,當隱藏UIKeyboard時,將分配內存並不釋放內存。如果是緩存的框架,有什麼方法可以清除它? 這些代碼是我用來創建UITextField,我怎麼隱藏UIKeyboard在顯示ARC上的UIKeyboard時發生內存泄漏

#import <UIKit/UIKit.h> 

    @interface SignInTextField : UITextField 

    -(id)initWithIndexPath:(NSIndexPath*)indexPath; 

    @end 

    #import "SignInTextField.h" 

    @implementation SignInTextField 

    -(id)initWithIndexPath:(NSIndexPath*)indexPath{ 
     self = [super init]; 
     if (self) { 
      if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 
       // iPad 
       self.frame = CGRectMake(110, 10, 600, 30); 
      } else { 
       self.frame = CGRectMake(110, 11, 150, 30); 
      } 

      self.tag = [indexPath row]; 
      self.returnKeyType = UIReturnKeyDone; 
      self.autocapitalizationType = UITextAutocapitalizationTypeNone; 
     } 
     return self; 
    } 

    //SettingTextField 
    SignInTextField *textField = [[SignInTextField alloc]initWithIndexPath:indexPath]; 
    textField.delegate = self; 

    #pragma mark - Text Field CallBack 
    -(void)textFieldDidBeginEditing:(UITextField *)textField{ 
     activeField = textField; 
    } 

    - (void)textFieldDidEndEditing:(UITextField *)textField { 

     if(textField.tag == 0) temp_email = [NSString   stringWithFormat:@"%@",textField.text]; 
     if(textField.tag == 1) temp_password = [NSString stringWithFormat:@"%@",textField.text]; 
    } 

    - (BOOL)textFieldShouldReturn:(UITextField *)textField { 
     [textField resignFirstResponder]; 
     return YES; 
    } 

This is leak point.

+2

請問,你能告訴我們你使用的代碼嗎? – Jean 2013-03-18 13:03:54

+0

什麼讓你覺得你有內存泄漏?如果您知道,請告訴我們您的儀器的讀數。 – Peres 2013-03-18 13:27:46

回答

4

當你打開第一次鍵盤,它是由iOS原生架構緩存。它由UIKit框架處理。

它不是內存泄漏。在下次需要顯示鍵盤時,應用程序將使用緩存鍵盤。

如果內存要求變高,本地框架將釋放緩存視圖(如果需要)。應用程序仍然需要內存,框架會產生相同的內存警告。

+0

親愛的Apurv。謝謝 !這是我想知道的! – JohnyDgoode 2013-03-18 13:41:22