gpt4 book ai didi

iphone - 在 ARC 上显示 UIKeyboard 时内存泄漏

转载 作者:可可西里 更新时间:2023-11-01 05:13:42 24 4
gpt4 key购买 nike

调用 UIKeyboard 时,会分配内存,而当 UIKeyboard 隐藏时,不会释放内存。如果是框架在缓存它,有没有办法清除它?这些代码是我用来创建 UITextField 以及我如何隐藏 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.

最佳答案

当您第一次打开键盘时,它会被 iOS 原生框架缓存。它由 UIKit 框架处理。

这不是内存泄漏。下次需要显示键盘时,应用程序将使用缓存的键盘。

如果内存需求变高, native 框架将在需要时释放缓存的 View 。应用程序仍然需要内存,框架将为此生成内存警告。

关于iphone - 在 ARC 上显示 UIKeyboard 时内存泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15477502/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com