Так я создал два текстовых поля в табличном представлении, и я освобождаю их в методе dealloc.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease];
}
cell.accessoryType = UITableViewCellAccessoryNone;
if ([indexPath row] == 0) {
text = [[UITextField alloc] initWithFrame:CGRectMake(5, 5, 300, 30)];
text.delegate=self;
text.userInteractionEnabled=NO;
text.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
if ( qNum-1 == 53 ) {
text.placeholder=@"Category";
}
[cell.contentView addSubview:text];
}
if ([indexPath row] == 1) {
text2 = [[UITextField alloc] initWithFrame:CGRectMake(5, 5, 300, 30)];
text2.delegate=self;
text2.userInteractionEnabled=NO;
if(qNum-1==53) {
text2.placeholder=@"Subcategory";
}
text2.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
[cell.contentView addSubview:text2];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
Проблема в том, что как только появляется виртуальная клавиатура, и я начинаю печатать в текстовые поля, память резко увеличивается. Может кто-нибудь, пожалуйста, помогите мне выйти из этой проблемы? Заранее спасибо.
Вот код, который я написал внутри методов делегата
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return YES;
}
- (void)textFieldDidBeginEditing:(UITextField *)textField{
if([text.text isEqualToString:@"United States"]||[text.text isEqualToString:@"Australia"]){
text2.userInteractionEnabled=NO;
item.title=@"State";
myPickerView.hidden=YES;
myPickerView2.hidden=NO;
[actionSheet showInView:mainView];
[actionSheet setBounds:CGRectMake(0, 0, 320, 400)];
}
}