這就是我在tableview中創建兩個文本域的方式,並且我在dealloc方法中釋放它們。當我輸入UITextfield時內存急劇增加
- (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) {
[email protected]"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) {
[email protected]"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;
[email protected]"State";
myPickerView.hidden=YES;
myPickerView2.hidden=NO;
[actionSheet showInView:mainView];
[actionSheet setBounds:CGRectMake(0, 0, 320, 400)];
}
}內
我認爲你的問題是在文本字段委託方法。請張貼該代碼,並在發佈時進行格式化。這會讓我們更容易幫助你。 –