2011-09-23 47 views

回答

0

你是什麼意思cell。只有在cell中有UITextField並且還將delegate設置爲self時,它纔會呼叫。

UITextField *txt=[[UITextField alloc]initWithFrame:CellFrame]; 
text.tag=indexPath.row; 
txt.delegate=self; 

[cell.contentView addSubview:txt];

那麼它肯定會調用textFieldShouldReturn方法。返回點擊

+0

我也有類似的,我嘗試添加我的代碼的答案,但我不得不等待8小時。我已經看過幾篇文章,告訴其他人有關於文件所有者和委託的類似問題,但是我怎樣才能以程序化方式製作文件所有者的一部分?如果那甚至是問題? –

0
@interface WordListTableController : UITableViewController <UITextFieldDelegate> 
{ 
} 

@end 

//自定義表格視圖單元格的外觀。 - (UITableViewCell的*)的tableView:(UITableView的*)的tableView的cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault  reuseIdentifier:CellIdentifier] autorelease]; 
} 

// Configure the cell... 
UITextField *FirstField = [[UITextField alloc] initWithFrame:CGRectMake(10, 10, 130, 25)]; 
FirstField.delegate = self; 
[FirstField setTag:indexPath.row]; 
FirstField.returnKeyType = UIReturnKeyNext; 
[cell.contentView addSubview:FirstField]; 
[FirstField release]; 


return cell; 
} 


// Handle any actions, after the return/next/done button is pressed 
- (BOOL)textfieldShouldReturn:(UITextField *)textfield 
{ 
[textfield resignFirstResponder]; 

return NO; 
}